Skip to content

Instantly share code, notes, and snippets.

@rmax
Created July 14, 2010 03:00
Show Gist options
  • Save rmax/474955 to your computer and use it in GitHub Desktop.
Save rmax/474955 to your computer and use it in GitHub Desktop.
/*
Dropbox.com hiring questions
http://www.dropbox.com/webengineer
1)
*/
function countdown(num) {
for (var i=0; i <= num; i += 1) {
setTimeout(function() {
alert(num - i);
}, i * 1000);
}
}
function countdown_good(num) {
var alert_func = function(m) {
return function() { alert(m); };
};
for (var i=0; i <= num; ++i) {
setTimeout(alert_func(num - i), i * 1000);
}
}
countdown_good(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment