Skip to content

Instantly share code, notes, and snippets.

@Bondifrench
Created June 5, 2014 00:56
Show Gist options
  • Save Bondifrench/190456e3fe414e7a6d6a to your computer and use it in GitHub Desktop.
Save Bondifrench/190456e3fe414e7a6d6a to your computer and use it in GitHub Desktop.
Recursion using a loop and without
for (var i=0; i<num; i ++) {
operation();
}
//Equivalent to
if (num <= 0) {return;} //or just return see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/return
operation()
return repeat(operation, --num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment