Guest User

Untitled

a guest
Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. // Exercise 2 - Closures
  2. // Wrap the following code in a closure and export only the "countdown" function.
  3.  
  4. // Code
  5. var index;
  6.  
  7. function log(){
  8. console.log(index);
  9. }
  10.  
  11. function iterate(){
  12. log();
  13. if(index>1) setTimeout(iterate, 1000);
  14. index--;
  15. }
  16.  
  17. function countdown(){
  18. index = 10;
  19. iterate();
  20. }
Add Comment
Please, Sign In to add comment