Calculate the Number of Vowels in a String
// Calculate the number of vowels in a string
const countVowels = string => {
const vowels = ['a', 'e', 'i', 'o', 'u'];
let count = 0;
string
.toLowerCase()
.split('')
.forEach(char => {
vowels.forEach(vowel => {
if (char === vowel) count++;
});
});
return count;
};
console.log(countVowels('queue')); // 4