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++) {
Regarding your code, your if condition needs no i2
if('aouie'.search(a[i]) > -1){
I wonder, why all that use of arrays and nested loops, the below regex
could do it better,
var str = "run forest, run";
var matches = str.match(/[aeiou]/gi);
var count = matches ? matches.length : 0;
alert(count + " vowel(s)");
Demo