Created
July 14, 2010 03:00
-
-
Save rmax/474955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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