🔒 Closed javascript

Status
Not open for further replies.

WeddingCrash

Honorary Poster
Mga sir may javascript ba kayo dyan na mag seseparate ng caps at lowercase letters sa vowel at consonant?

The The Quick Brown
CVowel:
LVowel:eiou
CConsonant:TQRN
LConsonant:hckbw

Wala kong mahanap na example sa google eh
 
Try paps

JavaScript:
const string = "ThE Quick Brown E U"

class find {
  constructor() {
    this.consonants = "bcdfghjklmnpqrstvwxz"
    this.vowels = "aeiuo"
    this.result = ""
  }
  findString(str) {
    this.result = {
      "Lvowels": this.Lvowels(str),
      "Cvowels": this.Cvowels(str),
      "Lconsonant": this.Lconsonant(str),
      "Cconsonant": this.Cconsonant(str)
    }
    return this.result
  }
  Lvowels(str) {
    const newStr = str.split("")
    const text = this.vowels.split("")
    let v = ""
    for (let i = 0; i < text.length; i++) {
      if (newStr.includes(text[i])) {
        v += text[i]
      }
    }
    return v
  }
  Lconsonant(str) {
    const newStr = str.split("")
    const text = this.consonants.split("")
    let v = ""
    for (let i = 0; i < text.length; i++) {
      if (newStr.includes(text[i])) {
        v += text[i]
      }
    }
    return v
  }
  Cvowels(str) {
    const newArr = str.split("")
    const text = this.vowels.toUpperCase().split("")
    let v = ""
    for (let i = 0; i < text.length; i++) {
      if (newArr.includes(text[i])) {
        v += text[i]
      }
    }
    return v
  }
  Cconsonant(str) {
    const newArr = str.split("")
    const text = this.consonants.toUpperCase().split("")
    let v = ""
    for (let i = 0; i < text.length; i++) {
      if (newArr.includes(text[i])) {
        v += text[i]
      }
    }
    return v
  }
}

const f = new find()

let Lvowels = f.findString(string)["Lvowels"]
let Cvowels = f.findString(string)["Cvowels"]
let Lconsonant = f.findString(string)["Lconsonant"]
let Cconsonant = f.findString(string)["Cconsonant"]

console.log(Lvowels)
console.log(Cvowels)
console.log(Lconsonant)
console.log(Cconsonant)
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 240
    Views
  • 2
    Participants
Last reply from:
Nel003

Trending Topics

Online now

Members online
1,123
Guests online
3,912
Total visitors
5,035

Forum statistics

Threads
2,307,160
Posts
29,177,037
Members
1,193,271
Latest member
tajdmagicdaragon
Back
Top