Created
April 19, 2020 14:09
-
-
Save colibie/6bfcbc46a1009070fd78d13de3a82927 to your computer and use it in GitHub Desktop.
A basic recursive function
This file contains 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
function hello(i) { | |
if (i < 0) return; // base case | |
console.log(i); | |
hello(--i); // recursive call | |
} | |
hello(5) // output: 5 4 3 2 1 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment