I am trying to loop through an array of strings using several for loops to call each array item. I'm having some trouble getting just the right code to pull it off. I have tried using global definitions of arrays and so on.
var An = new Array(
"11111100011111",
"11111000011111",
"11110011001111",
"11100000000111",
"11001111110011",
"10011111111001");
var Bn = new Array(
"1000000001",
"1001111001",
"1000000001",
"1000000001",
"1001111001",
"1000000001");
// This second part sits in a onload function.
var alphabet = "AB".split("");
for (x = 0; x < 6; x++) {
for (i = 0; i < 2; i++) {
var my_object = {};
my_object = window[alphabet[x] + 'n[' + i + ']'];
my_object = window[my_object].replace(/0/g, "B");
my_object = window[my_object].replace(/1/g, "_");
}
}
name? Why doesxgo until6, if you usealphabet[x], andalphabet.length==2?alphabethave here? What iswindow[my_object]supposed to accomplish? Where are you trying to accessAnandBn?window[alphabet[x] + 'n[' + i + ']'];is wrong and should bewindow[alphabet[x]+'n'][i];if at all. However, you shouldn't usewindowlike that, rather define your maps asvar arrays = {A:[…],B:[…]}and access them normally there