Creating 2d Array the ES6 way

August 04, 2017

const constructTwoD = ( columnNumber, rowNumber ) => [...Array(rowNumber)].map(row=>Array(columnNumber))

constructTwoD(2,3)
// => [[ , , ], [ , , ]]

Tagged withjavascript

Questions, Comments, Suggestions? Open an Issue