Skip to content

Instantly share code, notes, and snippets.

@muloka
Created March 3, 2011 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muloka/853425 to your computer and use it in GitHub Desktop.
Save muloka/853425 to your computer and use it in GitHub Desktop.
JSMC Exercise 2 - Closures
(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