Created
December 12, 2016 13:02
-
-
Save orenmizr/708ddb89b64783839535d6a99b7ddd16 to your computer and use it in GitHub Desktop.
vowelCounter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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