I'm currently working on debugging a specific portion of code for my class. I'm having trouble understanding why this JavaScript code is counting all letters instead of just vowels.
var text, i, sLength, myChar;
var count;
var text = prompt("Please type a phrase"); //changed to "phrase" and fixed ' to "
count = 0;
for (i = 1; i <= text.length; i+= 1){
myChar = text[i];
if (myChar == 'a' || myChar == 'o' || myChar == 'e' || myChar == 'u'){ //modified the conditionals for checking vowels
count += 1;
console.log('Vowel:', myChar);
}
console.log(myChar, count);
}
alert(count); //moved count into ()