"cannot read property 0 from undefined" in 2d array

Does anyone know why this gives an error? I have tried to do this for too long, and I cannot figure out how to understand it. These are errors with "it is impossible to read property 0 from undefined", but it is clearly defined. (or so I think)

var categorySix = [["test"]["test2"],["testing"]["one"],["two"]["three"]]; document.write(categorySix[0][0]); 
+4
source share
3 answers
 var categorySix = [["test","test2"],["testing","one"],["two","three"]]; 

Your syntax is off.

+6
source

You are declaring your 2D array incorrectly.

Try the following:

 var categorySix = [["test","test2"],["testing","one"],["two","three"]]; 
+1
source

You are not creating the array correctly.

I believe it should be

 var categorySix = [["test","test2"],["testing","one"],["two","three"]]; document.write(categorySix[0][0]); 

How to create a two-dimensional array in JavaScript?

0
source

All Articles