“2D -Array in JavaScript” Code-Antworten

JS -Array zweidimensional

// declaration of a two-dimensional array
// 5 is the number of rows and 4 is the number of columns.
const matrix = new Array(5).fill(0).map(() => new Array(4).fill(0));

console.log(matrix[0][0]); // 0
Evergreen Tomato

So lesen Sie 2 dimensionales Array in JavaScript


        
            
        
     activities.forEach((activity) => {
    activity.forEach((data) => {
        console.log(data);
    });
});
Friendly Fowl

Erstellen eines 2D -Arrays in JS

var x = new Array(10);

for (var i = 0; i < x.length; i++) {
  x[i] = new Array(3);
}

console.log(x);
Obedient Ox

JavaScript füllen 2 Dimensional -Array

const fillSquareMatrix = (size) => {
  return Array(size)
    .fill()
    .map((u,y) => Array(size)
         .fill()
         .map((u,x) => y * size + x + 1));
};

console.log(fillSquareMatrix(3));
Friendly Finch

Erstellen von 2D -Array in JavaScript

var [r, c] = [5, 5]; 
var m = Array(r).fill().map(()=>Array(c).fill(0));
Breakable Boar

2D -Array in JavaScript

function createArray(row,column) {
let arr = [];

for(var i=0; i<row; i++){
    arr[i] = [Math.floor(Math.random() * (10))];

    for(var j=0;j<column;j++){
        arr[i][j]= [Math.floor(Math.random() * (20))];
    }
}

return arr;
}

var arrVal = createArray(4, 5);

console.log(arrVal);
Outrageous Opossum

Ähnliche Antworten wie “2D -Array in JavaScript”

Fragen ähnlich wie “2D -Array in JavaScript”

Weitere verwandte Antworten zu “2D -Array in JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen