Code Lab

Count vowels

EasyStrings5 min

Write a function countVowels(text) that returns the number of vowels in a string. The vowels are the Latin letters a, e, i, o, u, in upper or lower case.

Examples

countVowels('Hello World')

Returns 3

These are e, o and o.
countVowels('Apple')

Returns 2

The capital A is a vowel too.
countVowels('rhythm')

Returns 0

Asked at Druva · Source

Loading the editor...
  1. InputcountVowels('Hello World')
    Expected3
  2. InputcountVowels('Apple')
    Expected2
  3. InputcountVowels('rhythm')
    Expected0

Hidden tests run on Submit.