How can I get the number of uppercase and lowercase vowels in a variable in JavaScript.
var person = new Object();
person = prompt("Introduce tus datos");
//Numero de vocales
var numVocales;
for (i = 0; i < 10; i++) {
var vocal;
if (i = 0){
vocal = "a";
}
else if (i = 1){
vocal = "e";
}
else if (i = 2){
vocal = "i";
}
else if (i = 3){
vocal = "o";
}
else if (i = 4){
vocal = "u";
}
else if (i = 5){
vocal = "A";
}
else if (i = 6){
vocal = "E";
}
else if (i = 7){
vocal = "I";
}
else if (i = 8){
vocal = "O";
}
else if (i = 9){
vocal = "U";
}
var aux = person.indexOf(vocal);
if(aux != -1){
numVocales++;
}
}
alert(numVocales);
I can not show the information in the alert, it may be that I have badly raised the for. Also I do not know if using indexOf () I get the first letter that concide.I mean that if I have ana, using indexOf () I would return one or two?