Answers for "javascriopt initialize 2d array with size"

1

js initialize 2d array

let data = [];
for (let row=0; row<rows; row++) {
    data.push(new Array(cols).fill('#'));
};
Posted by: Guest on July-22-2020
0

javascriopt initialize 2d array with size

function makeArray(w, h, val) {
    var arr = [];
    for(let i = 0; i < h; i++) {
        arr[i] = [];
        for(let j = 0; j < w; j++) {
            arr[i][j] = val;
        }
    }
    return arr;
}
Posted by: Guest on November-09-2020

Code answers related to "javascriopt initialize 2d array with size"

Code answers related to "Javascript"

Browse Popular Code Answers by Language