[Solved] Optimizing a while loop in Javascript


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

solved Optimizing a while loop in Javascript