i did understand why this function would count down till zero but I am not able to understand why it would count back from 0 to 3. can someone please make me understand.
Your code so far
<!-- file: index.html -->
/* file: styles.css */
/* file: script.js */
// User Editable Region
countDownAndUp(number - 1);
console.log(number);
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Challenge Information:
Learn Recursion by Building a Decimal to Binary Converter - Step 64
I think you’re asking how recursion works?
You may have to google this topic more for additional reading like:
In general though, each time a function is calling itself, the call stack is being added to so that by the time the final call to the function is done, the call stack has a list of functions that it needs to ‘unravel’. That means we need to return to the prior calling function and the one prior to that and the one prior to that etc until the call stack is empty. The code that runs during this ‘unraveling’ causes the the effect of counting back up.
Go to step 65 as well as they continue explaining there.
i have the same question. did you ever figure it out? if so, i’m happy to hear an explanation. i’m going to deep dive the topic now so hopefully i can understand it too