← Back to challenges

How Many Vowels?

JavaScriptHardregexstringsloopsinterview

Instructions

Create a function that takes a string and returns the number (count) of vowels contained within it.

Examples

countVowels("Celebration") ➞ 5

countVowels("Palm") ➞ 1

countVowels("Prediction") ➞ 4

Notes

  • a, e, i, o, u are considered vowels (not y).
  • All test cases are one word and only contain letters.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Pi to N Decimal Places