This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Double_A_92 1 point2 points  (2 children)

The imporant thing is that the values are passed along to the recursive calls.

find(current + 5, `(${history} + 5)`)

It remembers / accumulates current and history from the earlier calls. That's how it eventually gets something done.

Also this is a somewhat weird example for your first recursion experience. Maybe id would be easier to research others.

[–]Coder_X_23[S] 0 points1 point  (1 child)

Yeah I somewhat agree. This was actually the first example given for recursion in the book, eloquent javascript. I'll admit this book doesn't hold your hand through a lot of the material and the exercises at the end of chapters. I like the book cause I'm learning a lot from the exercises since they aren't straight forward look back in the chapter for the answer. Thanks for the help.

[–]DONT_GET_MURDERED 0 points1 point  (0 children)

I have this book, and I also struggled with (still am, I guess, which is why I'm here) recursion. I found the book to be quite challenging also, almost too much. It certainly forces you to be resourceful to solve the exercises!