Skip to content

Instantly share code, notes, and snippets.

@calderonroberto
Created November 20, 2015 06:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save calderonroberto/b7a536f9a251e03a8431 to your computer and use it in GitHub Desktop.
Vowel Count with IndexOf
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