I have a nested for loop that creates a empty string value that represents a multidimensional array. Once the for loops have finished the result is something like this:
"[[0,0,0,0],[0,0,0,0]]"
I would like to add this to a multidimensional array within my code, how would i do this?
I have tried:
map = eval("[[0,0,0,0],[0,0,0,0]]");
but this does not produce the correct multidimensional array i am looking for.
I am looking to be able to use the array like this:
map[0][1] == 1;
Thanks
You could parse the string using
JSON.parse()(MDN docu).However, in your example there is no entry equaling
1, so you requirementmap[0][1] == 1wont be fulfilled that way.