DEV Community

loading...

Discussion on: Daily Challenge #3 - Vowel Counter

Collapse
centanomics profile image
Cent

My solution is a bit longer because I don't know regex, but it gets the job done.

CodePen


const countVowels = text => {
  let count = 0;
  text.toLowerCase().split("").forEach(char => {
    if (char === "a" || char === "e" || char === "i" || char === "o" || char === "u")
      count++;
  })
  return count;
}