๐Ÿ”’ 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
  • 229
    Views
  • 2
    Participants
Last reply from:
Nel003

Online now

Members online
1,021
Guests online
884
Total visitors
1,905

Forum statistics

Threads
2,276,231
Posts
28,968,504
Members
1,231,175
Latest member
cflakashi
Back
Top