1
I’m making a Java Script code where I need everything inside the for to be executed and then increment the for including a setTimeout. In the current code it executes everything without waiting for the setTimeout to run. Follow code example:
var teste = function () {
for (let i = 0; i < 100; i++) {
console.log(i)
setTimeout(function () {
console.log("opaopa")
return
}, 5000);
}
}
teste();
In this case you would need the setTimeout to perform afterwards.
Apparently you want to make a process repeatedly. Already tried to see if it would not be more appropriate to use
setInterval
in place ofsetTimeout
?– tvdias
I will look to know about the setInterval thank you very much!
– Matheus Felix