Skip to content

Instantly share code, notes, and snippets.

@malte-j
Created September 21, 2017 15:33
Show Gist options
  • Save malte-j/b06fdf03720e7793636fb704beeadb4c to your computer and use it in GitHub Desktop.
Save malte-j/b06fdf03720e7793636fb704beeadb4c to your computer and use it in GitHub Desktop.
JS 2D Array
function Create2DArray(rows, columns) {
var arr = [];
for (var i = 0; i < rows; i++) {
var col = [];
for (var j = 0; j < columns; j++){
col[j] = 0;
}
arr[i] = col;
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment