0
Necesito un array que cuente las letras que ingreso
4 Respostas
+ 3
@Alexito De nada :)
+ 2
English translation:
"I need an array that count the characters that I enter"
in JS:
var string = prompt('write your sentence here');
var array = [];
for (var i=0; i<string.length; i++) {
array.push(string[i]);
}
alert(array.length);
Or maybe:
var string = prompt('write your sentence here');
var array = string.split(''); // I'm not sure that this works, somebody experienced here?
alert(array.length);
Do you need to count how many times every character appears? Then is a little larger code.
0
gracia
0
gracias