Basic JavaScript recursion resource

One of the most intimidating parts of programming is the concept of recursion– that is, calling a function within itself. The function calls itself until it reaches a “base case” where something is returned (the base case is similar to what you might see between the parentheses at the beginning of a while loop). A resource I found useful as an introduction to recursion was Codecademy’s “Recursion in Javascript” lesson set:

While recursion is a difficult concept, Codecademy interactively walks the user through a set of lessons that start with the most basic of loops and end with some practical examples of recursion implementation. As someone who has been using recursive algorithms regularly over the past three weeks (Hack Reactor’s curriculum definitely does not shy away from the concept), I wish I had come across this resource sooner. However, it was still an excellent review for me, and I plan to take my strengthened comprehension of recursion and apply it to some of the more difficult recursive problems, such as those involving permutations.

For those having trouble following a function through multiple levels of recursion and determining the order of calculations, you are far from alone. Coming up with a visual representation of the problem can help, and walking through each step methodically and predicting what the program will do at each point is also a good idea. Good luck!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s