Skip to content

Instantly share code, notes, and snippets.

@AkimaLunar
Created April 18, 2017 05:08
Show Gist options
  • Save AkimaLunar/bf2d8f3bcbfbda63e9971d6352776c84 to your computer and use it in GitHub Desktop.
Save AkimaLunar/bf2d8f3bcbfbda63e9971d6352776c84 to your computer and use it in GitHub Desktop.
function timer(t){
setTimeout(function() {
console.log('Right timer: ' + t +'s');
}, t * 1000 );
}
for (var i = 0; i < 5; i++) {
timer(i);
}
for (var i = 0; i < 5; i++) {
setTimeout(function() {
console.log('Timer 1: i = ' + i);
}, i * 1000 );
}
function timer2() {
for (j = 0; j < 5; j++) {
setTimeout(function() {
console.log('Timer 2: j = ' + j);
}, j * 1000 );
}
}
timer2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment