Return the number (count) of vowels in the given string.
We will consider a, e, i, o, and u as vowels for this Kata.
The input string will only consist of lower case letters and/or spaces.
| function getCount(str) { | |
| return (str.match(/[aeiou]/ig)||[]).length; | |
| } |
| function getCount(input) { | |
| var vowelsCount = 0; | |
| var inputLetters = input.split(""); | |
| const vowels = ["a","e","i","o","u"]; | |
| vowels.forEach(function(vowel) { | |
| inputLetters.forEach(function(inpLetter) { | |
| if (inpLetter === vowel) { | |
| vowelsCount++; | |
| } | |
| }); | |
| }); | |
| return vowelsCount; | |
| } |