These are examples of using recursion and folding (aka reduce) in JavaScript. Starting point is master branch, solutions we came up with were pushed to solved.
For a somewhat more advanced example of using recursion in the context of a React app: