Push numbers in an array using for loop

Push numbers in an array using for loop
0

#1

How can I push numbers using for loops

function factorialize(num) {
  let arr = [];
for (let i = 0;i <= num ; i++){
 return arr.push[i];

}

}

console.log(factorialize(5));

arr should be

[0,1,2,3,4,5]

#2

return can only happen once. As soon as a return statement is reached, the function ends.


#3

your return needs to be outside the for loop. Once the loop goes through once it hits return and exits. Leaving return out of the for loop lets the loop go all the way through.

function factorialize(num) {
  let arr = [];
for (let i = 0;i <= num ; i++){
arr.push[i]

}
return arr;
}