function x(){
for(var i=1;i<=5;i++){
setTimeout(function (i){
console.log(i)
},i*1000)
}
}
x();
here is my code can anyone help me out why my code is printing """"undefined""" in place of i
I've been searching how to use the setTimeout function inside a loop but the documentation about this stuff seems limited, I want to make a setTimeout inside a for loop. it would be great if you help me out with this