I want to push items in a list using a for loop and print every step with a delay. Instead I get in every iteration the complete list.I guess this is a scope problem but I cant figure a solution.
Here is my code:
function printNumber(num,i){
setTimeout(()=>console.log(num),500*i);
}
let numbers = [50];
for(let i=1; i<=10; i++){
printNumber(numbers,i);
numbers.push(i);
}