Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript fill 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));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #fill #dimensional #array
ADD COMMENT
Topic
Name
9+7 =