Created
March 3, 2011 20:09
-
-
Save muloka/853425 to your computer and use it in GitHub Desktop.
JSMC Exercise 2 - Closures
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
(function (functionName, container){ | |
var index; | |
function log(){ | |
console.log(index); | |
} | |
function iterate(){ | |
log(); | |
if(index>1) setTimeout(iterate, 1000); | |
index--; | |
} | |
countdown = function (){ | |
index = 10; | |
iterate(); | |
} | |
return container[functionName] = countdown; | |
})('countdown',this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment