how creating a JavaScript array containing 1 through to x where x is only known at runtime without the loop.
var arr = [];
for (var i = 1; i <= x; i++) {
arr.push(i);
}
how creating a JavaScript array containing 1 through to x where x is only known at runtime without the loop.
var arr = [];
for (var i = 1; i <= x; i++) {
arr.push(i);
}
This is a duplicate of this issue
here is the answer anyway
const arr = [...''.padEnd(N)].map((_,i)=>i+1)