Learn 2D ARRAYS in JavaScript in 6 minutes! ⬜
19.9 هزار بار بازدید -
8 ماه پیش
-
// 2D array = multi-dimensional
// 2D array = multi-dimensional array that stores a matrix
// of data in rows and columns.
// Useful for games, spreadsheets, or representing images
const matrix = [ [1, 2, 3],
[4, 5, 6],
[7, 8, 9]];
//matrix[0][0] = 'X';
//matrix[0][1] = 'O';
//matrix[0][2] = 'X';
//matrix[1][0] = 'O';
//matrix[1][1] = 'X';
//matrix[1][2] = 'O';
//matrix[2][0] = 'X';
//matrix[2][1] = 'O';
//matrix[2][2] = 'X';
for(let row of matrix){
const rowString = row.join(' ');
console.log(rowString);
}
// of data in rows and columns.
// Useful for games, spreadsheets, or representing images
const matrix = [ [1, 2, 3],
[4, 5, 6],
[7, 8, 9]];
//matrix[0][0] = 'X';
//matrix[0][1] = 'O';
//matrix[0][2] = 'X';
//matrix[1][0] = 'O';
//matrix[1][1] = 'X';
//matrix[1][2] = 'O';
//matrix[2][0] = 'X';
//matrix[2][1] = 'O';
//matrix[2][2] = 'X';
for(let row of matrix){
const rowString = row.join(' ');
console.log(rowString);
}
8 ماه پیش
در تاریخ 1402/08/15 منتشر شده
است.
19,930
بـار بازدید شده