I have a 2D JavaScript array;
grid = [ [ a, b],
[ c, d]]
To access it's elements, i could use;
grid[ i ] // that's [ a, b] or [ c, d]
As an element of a sub-array, how do i address just "a" for instance?
Edit: The code is actually from a three.js scene where each element is represented by a cube i.e the array is a grid of cubes.
The program is set up such that when i click on one of these cubes, an event is triggered to display the name (string) of each of them. When i use
grid [ i ],
Each row returns the appropriate elements;
[ a, b ] or [ c, d].
So to get the individual elements of each row, i figured it must be;
grid [ i ][ j ],
But when i ran the code, with this it always returned "undefined" so i thought the syntax was wrong....hence the original post.
Please what do i do to get a valid result?