Re:Dropbox is hiring a Web Engineer
by sgk284 on Friday July 02, 2010 @04:28PM
(#1482241)
I understand the scoping issue here, but the recursive solution is just all around better:
Note: I'm aware that the dropbox version shows the first alert without any delay, whereas this waits a second before showing anything. This is slightly different behavior, but arguably acceptable.
[ Parent
| on HN ]
Re:Dropbox is hiring a Web Engineer
by abstractbill on Friday July 02, 2010 @06:32PM
(#1482592)
You can make the recursive solution work without any delay:
function countdown(n) {
if(n >= 0) {
alert(n);
setTimeout(function() {countdown(n-1);}, 1000);
}
}