Search
 
SCRIPT & CODE EXAMPLE
 

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];
  }
}
Comment

two dimensional array traversing in javascript

const numbers = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9, 10, 11],
];

for (let i = 0; i < numbers.length; i++) {
  for (let j = 0; j < numbers[i].length; j++) {
    console.log(`Index Point [${i}, ${j}], value = ${numbers[i][j]}`);
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: node js orderby method 
Javascript :: how to convert numbers to roman numerals in javascript 
Javascript :: pass a callback funcion into an async function node js 
Javascript :: submit form on ctrl enter 
Javascript :: Plumsail change the size of the dialog window 
Javascript :: js draw number in range 
Javascript :: draw image inside canvas width 100% 
Javascript :: createfileinput javascript 
Javascript :: for (i = 0; i < N; i++) for (j = 0; j < N; j++) { .... some O(1) code ... } 
Javascript :: MAP METHOD. IMPORTANT 
Javascript :: conditional ternary statement only one return 
Javascript :: javascript Vue Component Loading Before Vuex Data Is Set 
Javascript :: getting json from response using getSync method 
Javascript :: angularjs how to get a response from a post request 
Javascript :: angularjs Split date and time from api response 
Javascript :: How can I save a option from multi select in Angular 
Javascript :: I am getting an error "createSpyObj requires a non-empty array" with running unit tests, which were executed perfectly before 
Javascript :: Error thrown after ending the audio track / array of tracks in React Native Track Player 
Javascript :: adding to an array in js 
Javascript :: react open popup to upload image file 
Javascript :: upload node js 
Javascript :: Sequelize conditional shorthands 
Javascript :: clickable image full screen javascript 
Javascript :: bullet mechanism in phaser 
Javascript :: Adding Proof of Work to blockchain 
Javascript :: var a = x || y Variable Assignment In JavaScript 
Javascript :: what does the text before an object stand for in js 
Javascript :: registration page validation in react 
Javascript :: jQuery Misc Methods 
Javascript :: check token balance of an address in js 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =