I have a code like this:
var increment = 200;
for (var j=0; j<10; j++){
var print = function(){ console.log("===== J ===== "+j); }
setTimeout(print, increment);
increment+= 200;
}
Console always print 10. I think that could be for statement and setTimeout are executed in different threads. How i can do to print the correct value of j?
Thanks in advance.