I'm learning JavaScript and I came across the following situation:
My code:
alfabetoMadegues = "jngmclqskrzfvbwpxdht"
var listaLetras = Array.from(alfabetoMadegues);
dicionario_Madegues = {};
for (var i = 0 < listaLetras.length; i++;) {
listaLetras.forEach(element => {
dicionario_Madegues[element] = i;
})
};
If "j" is the first element of the array Why "j" is receiving 2 instead 0?. Why am i getting this result?
The expected result should be:
"j" 0
"n" 1
"g" 2
"m" 3
"c" 4
"l" 5