Read the question, write JavaScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one word and log how many vowels (a, e, i, o, u) it contains.
Count both cases — lowercase the word first so you only check one set.
Input. One line: a word.
Output. One integer: the vowel count.
Examples
Input
Programming
Output
3
Input
sky
Output
0
Hint
- Loop over the characters with for (const c of word).
- "aeiou".includes(c) is a compact vowel test.
Show correct code
Peek only after you have tried. You can still Check your own version.
const word = readLine().trim().toLowerCase();
let count = 0;
for (const c of word) if ("aeiou".includes(c)) count++;
console.log(count);
main.jsconsole.log · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.