I start out with an array of strings where each element of the array is separated by "//". e.g. temp[0] = {"sky//hi//pi"}
, temp[1] = {"fish//steak//carrot"}
. Now my code looks like this:
for (var i = 0; i < temp.length ;i++)
{
window.data_arrays = Array(2);
window.data_arrays[i] = temp[i].split("//");
}
What I'm trying to do is to make data_arrays into a 2 dimensional array...so for the example it would be like temp[0][0] = "sky"
, temp[0][1] = "hi"
, temp[1][0] = "fish"
.
However the code doesn't work. Can someone please help me out? Thanks. (reason why I'm assigning it to window is because I need to access this variable in another file later)
temp[0] = {"sky//hi//pi"}
is not valid JavaScript. – Felix Kling Jul 13 '11 at 15:20