Sorry if this is silly, but I don't understand the point of the -1?

Continuing the discussion from freeCodeCamp Challenge Guide: Replace Loops using Recursion:

As I said, the code isn’t necesarily hard to understand, except that I don’t understand what’s the point of the n - 1? Is it because it’s supposed to start the count from -1 until it goes up to 0 so it can start the additions? Again, I apologize but this part has me very confused as to the why.

If I understand you correctly, then yes. The one of the hard things for people to understand is that these functions keep getting called and not completing until the base case is reached (n === 0) and then they start unwinding off the calls stack. But I’m inferring from your question that you are understanding that.

1 Like

Yes, I wasn’t sure if ther was any other reason for it to be that way, now I’m clear on that, so, much appreciated!

1 Like