Why does this piece of code count back up again? learn recursion by building a decimal to binary converter - Step 65

const countDownAndUp = (number) => {
console.log(number);

if (number === 0) {
console.log(“Reached base case”);
return;
} else {
countDownAndUp(number - 1);
console.log(number); //***why does this go back up to 1 after number reaches 0
}
};
countDownAndUp(3);

Welcome to the forum @luisrjr

Here is a forum post on recursion you may find helpful.

Happy coding

2 Likes

Thank you! Very abstract to how my small brain works :slight_smile: ,but I get it!

1 Like