The explanation on recursion in my opinion in this challenge is not that understandable. I already got the answer I sought after spending much time searching. Even the help video has no video and has an article that doesn’t explain much.
The best video that helped to understand the call stack is this
I hope you will do some changes on the challenge for people not to get lost in it.
Many thanks
Your code so far
function countdown(n) {
// base case
if (n === 1) return [1];
const output = [n]; // [2]
return output.concat(countdown(n - 1)); // [2, 1]
}
countdown(5);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
Thanks for your enthusiasm for helping improve freeCodeCamp. If you have a specific suggestion on how to improve the content in the lesson, you can go to the freeCodeCamp GitHub and create an issue on the issue tracker.
However, it has been my experience that recursion is a particularly difficult topic to understand, requiring synthesis of many previous ideas. Because of this complexity, I’m not sure that there is a single ‘right’ way to teach recursion that every learner can understand.
True recursion, as I read, is a tough topic to understand.
But in the mentioned challenge, there is no explanation or example of what is exactly going on. The stack call is not even mentioned. It’s like I am starring at a blue sky trying to find a star.
When I read this line for the first time “However, notice that multiply(arr, n) == multiply(arr, n - 1) * arr[n - 1] .” I was like ha!? Plus the rest of the explanation.
There should be an example with a given array and showing how the functions stacks.
Example:
function multiply(arr, n) {
if (n <= 0) {
return 1;
} else {
return multiply(arr, n - 1) * arr[n - 1];
}
}
var heaven = [1,2,3];
console.log(multiply(heaven,3));
etc
It looks like there is a challenge missing. before this challenge maybe there was a challenge that talks about how functions stack. But even though if that existed still the explanation is not understandable in this challenge.
I am not complaining. I know the course is free and i thank you guys for this too much.
But this challenge needs to be corrected for others to understand exactly whats going on in the problem. From all the challenges that I passed, I realized this one is not explained properly. When I came to this challenge I thought maybe I can write an article to explain this challenge in an understandable way as possible.
Anyway. just wanted to point out this challenge need fixing. maybe i will check the issue tracker thing later.