empty × 2 javascript code example
Example: javascript two dimensional array
var grid = [];
iMax = 3;
jMax = 2;
count = 0;
for (let i = 0; i < iMax; i++) {
grid[i] = [];
for (let j = 0; j < jMax; j++) {
grid[i][j] = count;
count++;
}
}
// grid = [
// [ 0, 1 ]
// [ 2, 3 ]
// [ 4, 5 ]
// ];
console.log(grid[0][2]); // 4