Count the Vowels
JavaScript
20 pts
Count the Vowels
Write a function countVowels(text) that returns how many vowels (a e i o u, small or capital) the text has. Loop over the letters with for…of and check each one with "aeiou".includes(…). Tip: turn the text into small letters first.
Then loop over the array cities with a second for…of and print one line per city. Expected output:
Asmara: 3 vowels Keren: 2 vowels Mendefera: 4 vowels
Checklist
- Write
countVowels(text)that counts small and capital vowels. - Use
for…offor the letters and for the cities. - Print one line per city.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
