One-line create 2D Matrix in Javascript

The one-line code is: a = Array(5).fill(0).map(x => Array(10).fill(0)) “a” can be created with let, var, or const as needed. Array(5) creates an Array with 5 items. .fill(0) fills the 5 items with 0 .map will iterate through each of the 5 items. In this case, the .map function is taking an arrow function x […]

Read More