Skip to content

Instantly share code, notes, and snippets.

@ahoward ahoward/countdown.js
Created Jan 18, 2011

Embed
What would you like to do?
capturing deferred state with a closure
// a solution to http://blog.abhiomkar.in/2010/07/03/javascript-code-challenge-by-dropbox-team/
//
var countdown = function(num){
for (var i = 0; i <= num; i += 1) {
(function(i){ setTimeout(function(){ alert(num - i); }, i * 1000); })(i);
}
}
countdown(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.