🔒 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
  • 243
    Views
  • 2
    Participants
Last reply from:
Nel003

Trending Topics

Online now

Members online
362
Guests online
3,424
Total visitors
3,786

Forum statistics

Threads
2,331,971
Posts
29,261,465
Members
1,147,943
Latest member
Jrob30
Back
Top