Last active
March 4, 2021 16:37
-
-
Save charlesroper/8de95087e618f9662b65e8ba2760819a to your computer and use it in GitHub Desktop.
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 countup (n) { | |
console.log(`we are in ${arguments.callee.name}(${n})`); | |
console.log(`is ${n} < 1?`, n < 1); | |
if (n < 1) { | |
console.log(`so we're going to return [] back to the caller\n↓`); | |
return []; | |
} | |
console.log(`so we call countup(${n-1})\n↓`); | |
const countArray = countup(n-1); | |
console.log(`we are back in ${arguments.callee.name}(${n})`); | |
console.log(`now we push ${n} into countArray, which is currently [${countArray}]\n↓`); | |
countArray.push(n); | |
return countArray; | |
} | |
console.log(countup(5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment