Learn and Understand Recursion in JavaScript
Brandon Morelli

A couple of helpful hints:

I notice that the fib function returns ‘undefined’ in the termination condition, had you considered returning a value e.g. zero or null, or raising an exception instead? It can be difficult to tell an error condition from a bug otherwise.

Your second example the string reverser has no termination condition, which will cause the function to fail at runtime e.g. revStr(42) will result in

> TypeError: str.substr is not a function

I recognise this article may not be the right place to deep dive into exception handling or the semi-predicate problem, but at least mentioning it and providing a link elsewhere might at least help devs realise that there is more to this when they are ready.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.