2d Arrays & Nested Loops

Lesson 25
Author : Afrixi
Last Updated : October, 2017


Table of Content

Code

CopynumberGrid = [ [1, 2], [3, 4] ];

numberGrid[0][1] = 99;
document.write(numberGrid[0][0] + "<br>");
document.write(numberGrid[0][1] + "<br>");

for(var i = 0; i < numberGrid.length; i++){
     for(var j = 0; j < numberGrid[i].length; j++){
          document.write(numberGrid[i][j] + ", ");
     }
     document.write("<br>");
}