[Solved] Optimizing a while loop in Javascript

[ad_1]

To get an array like this, simply use Array.from

const additionPerLoop = 1000;
const amount = 10000;
const res = Array.from({length: Math.floor(amount / additionPerLoop) + 1}, (_, i) => i * additionPerLoop);

console.log(res);

0

[ad_2]

solved Optimizing a while loop in Javascript