Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

traverse 2d array js

// Declare 2D array of values 0 and 1
let arr = [[0, 1], [0, 0], [1, 1]];
// Nested for loops
for (let i = 0; i < arr.length; i++) {
  for (let j = 0; j < arr[i].length; i++) {
    let value = arr[i][j];
  }
}
 
PREVIOUS NEXT
Tagged: #traverse #array #js
ADD COMMENT
Topic
Name
3+2 =