Quantcast
Channel: w3mentor » Javascript
Viewing all articles
Browse latest Browse all 100

Create a 4×4 multidimensional array in Javascript

$
0
0
Array.matrix = function (m, n, initial) { var a, i, j, mat = []; for (i = 0; i < m; i += 1) { a = []; for (j = 0; j < n; j += 1) { a[j] = initial; } mat[i] = a; } return mat; }; var myMatrix = Array.matrix(4, 4, […]
Continue reading...

Viewing all articles
Browse latest Browse all 100

Trending Articles