I use this code to search and count vowels in the string,
a = \"run forest, run\"; a = a.split(\" \"); var syl = 0; for (var i = 0; i < a.length - 1; i++) {
Try:
a = "run forest, run"; var syl = 0; for(var i=0; i -1){ syl++; } } alert(syl+" vowels")
First, the split is useless since you can already cycle through every character.
Second: you need to use i, this gets the last character in the string, too.
i, this gets the last character in the string, too.