Use a for-loop that pushes to an array:
function count(n){
let arr = [];
for (let i = 1; i <= n; i++){
arr.push(i);
}
return arr;
}
console.log(count(5));
console.log(count(7));
solved JavaScript, how to create an array that sequentially counts till N? [closed]