I am trying to use the contents of a variable as the name of an Array, but it is returning a letter of the contents of that variable.
Example:
var posicaoArray = 2;
var nomeArray = "frutas";
var frutas = new Array();
frutas [0] = "Banana";
frutas [1] = "Melancia";
frutas [2] = "Maçã";
frutas [3] = "Laranja";
document.write(nomeArray[posicaoArray]);
It will return the letter "u", letter number 2 of the word "fruit" if we count from 0, instead of appearing "apple".
Why does this happen?