Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascriopt #initialize #array #size
ADD COMMENT
Topic
Name
2+8 =