Count the vowels
Inputs
text is 0 to 20 lowercase letters (a to z).
Your tasks
- Create a number
countthat starts at 0. - Use a loop over each character of
text. Add 1 tocountwhen the character is one of a, e, i, o, u. - Complete
countVowelsso it returnscount. Return it, do not print it.
Example
With text = "education", countVowels returns 5.
Rules
- Only these five letters count as vowels.
Test data
TEST DATA 1: text is "education"
TEST DATA 2: text is ""
Practice focus
Text is just a list of characters, so everything you know about lists applies. String problems in interviews are array problems with letters.