javascript - Why does this vowel counting fail? -


function vowelcount(str) {   var counter=0;   for(i=0; i<str.length; i++)   {     if (/[aeiouaeiou]/g.test(str[i]))     {       counter += 1;     }   }   return counter;  }  vowelcount("aaaeeebziiiooouu"); 

this returns "14" on repl.it, returns "7" on coderbyte.

what have missed?

@user1544566 discovered answer question , posted in comments, didn't write answer it. said:

coderbyte hates g (thanks mr. hazmat) removing g makes work. 

apparently, coderbyte runs code submitted incorrectly. appears you've found bug. i'd consider reporting them.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -