Created
November 20, 2015 06:26
-
-
Save calderonroberto/b7a536f9a251e03a8431 to your computer and use it in GitHub Desktop.
Vowel Count with IndexOf
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
var withIndex = function (s) { | |
var vowels = 0; | |
var vowelArray = ["a","e","i","o","u"]; | |
for (var i = 0; i < s.length-1; i++){ | |
if (vowelArray.indexOf(s[i].toLowerCase()) !== -1 ) { | |
vowels++; | |
} | |
} | |
return vowels; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment