function generalFunctionThatHappensWhenYouClickAButton(){
for (let i = 0; i < 1000; i++){
setTimeout(animateSquares(), 10000);
}
}
function animateSquares(){
topPositionThatAdds++;
console.log(topPositionThatAdds);
}
The function animateSquares()
will execute 1000 times as planned, but all at the same time and not waiting 10,000 ms for each execution, as I planned to.
Does anyone know why this is happening?
Thank you for your time.