+ 1
Whenever I use setTimeout in sololearn nodejs, it says terminated. Why please?
5 ответов
+ 1
more over write console.log in for loop before setTimeout, and you see that when setTimeout called your loop finished.
it is idea of async functions.
+ 1
george I didn't get you clearly. I wanted to display the numbers after every second. From 0 to 5.
+ 1
Please use setInterval function.
+ 1
let index=-1;
const id=setInterval(f,1000);
function f(){
console.log(++index);
if(index==5){
clearInterval(id)
}
}
+ 1
george thanks a million 😊😊😊😊