← Back to challenges

Recursion: Count Vowels

JavaScriptHardrecursionstringsregex

Instructions

Write a function that recursively returns the number of vowels in a string.

Examples

countVowels("apple") ➞ 2

countVowels("cheesecake") ➞ 5

countVowels("bbb") ➞ 0

countVowels("") ➞ 0

Notes

  • All letters will be in lower case.
  • Vowels are: a, e, i, o, u.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Intro to Nested Loops