Created
June 5, 2014 00:56
-
-
Save Bondifrench/190456e3fe414e7a6d6a to your computer and use it in GitHub Desktop.
Recursion using a loop and without
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
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