Skip to content

Instantly share code, notes, and snippets.

@dsimard
Created May 19, 2010 14:50
Show Gist options
  • Select an option

  • Save dsimard/406379 to your computer and use it in GitHub Desktop.

Select an option

Save dsimard/406379 to your computer and use it in GitHub Desktop.
Count to 10 recursively with closures
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