Exercise · Conditions and loops · lesson 12 of 13
Exercise: count the vowels
Write a function function countVowels(text) that returns how many vowels the string text contains. The vowels are a, e, i, o and u.
countVowels("javascript")→3countVowels("hello world")→3countVowels("rhythm")→0
Constraints: text consists of lowercase Latin letters and spaces and may be an empty string, for which the answer is 0; the letter y does not count as a vowel.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.