Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js arrays in arrays

// This is known as a 2-dimensional array (or matrix)
let tester = [
	[2,5], // 0
	[10,6] // 1
/*   ^  ^
     0  1
*/
];

// Get the element on the first row and the second column
console.log(tester[0][1]);

// iterate through each row and return the first column
for(let i = 0; i < tester.length;i++){
	console.log(tester[i][0])
}
 
PREVIOUS NEXT
Tagged: #js #arrays #arrays
ADD COMMENT
Topic
Name
9+6 =