Created
May 19, 2010 14:50
-
-
Save dsimard/406379 to your computer and use it in GitHub Desktop.
Count to 10 recursively with closures
This file contains hidden or 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
| var count = function countToTen(i) { | |
| if (i <= 10) { | |
| console.log(i); | |
| count(i+1); // Call count with the power of closures | |
| } | |
| } | |
| count(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment