One Liner

Create array of n elements

const generateArray = (n) => Array(n).fill(0);

Example

generateArray(4); //  [0, 0, 0, 0]
Last Update: 05:54 - 19 April 2024

On this page