August 04, 2017

Creating 2d Array the ES6 way

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

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