Last updated 4 years ago
Was this helpful?
generate empty array and fill with 0(zero) for iterate
iterate the process-1 array and fill with (index + 1) * x
x
const countBy = (x, n) => new Array(n).fill(0).map((v, i) => x * (i + 1));