Healthy.io interview question

A JavaScript problem with recursion