Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Exercise 2 - Closures
- // Wrap the following code in a closure and export only the "countdown" function.
- // Code
- (function (win, name) {
- var index;
- function log(){
- console.log(index);
- }
- function iterate(){
- log();
- if(index>1) setTimeout(iterate, 1000);
- index--;
- }
- function countdown(){
- index = 10;
- iterate();
- }
- win[name]= countdown;
- })(this, 'countdown')
Add Comment
Please, Sign In to add comment