Skip to content

Instantly share code, notes, and snippets.

@orenmizr
Created December 12, 2016 13:02
Show Gist options
  • Save orenmizr/708ddb89b64783839535d6a99b7ddd16 to your computer and use it in GitHub Desktop.
Save orenmizr/708ddb89b64783839535d6a99b7ddd16 to your computer and use it in GitHub Desktop.
vowelCounter
function getCount(str) {
var vowelsCount = 0;
strArr = str.split('');
strArr.forEach(vowelCounter);
return vowelsCount;
// helper
function vowelCounter(letter) {
var vowels = ['a','e','i','o','u'];
if( vowels.indexOf(letter) !== -1) vowelsCount++;
}
}
console.log(getCount('abracadabra'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment