Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Just checking the available ?? 0 would be enough instead of divsion to NaN. Recipe will always have some vlaue I guess
This comment is hidden because it contains spoiler information about the solution
You get better at anything by practicing it. So make a game out of it where you apply it every chance you get. Your approaches in the beginning will look and feel awkward, but you'll get better with practice. Eventually you will arrive at a point where functional makes as much sense as the imperative loop-based implementations -- usually with a lot less code because the loops are hidden behind the higher-ordered functions. Once you are used to functional approaches you are likely to find that bugs are more evident because the loop mechanics aren't in the way (that and you'll learn to avoid side effects, mutability, etc... you'll solve problems with functional composition, keeping your lambda's/arrow-functions short and sweet.)
At its root, functional list processing is map, filter and reduce. But there are lots of variations of these operations that have names that can make your functional code speak more to its intent than its imperative equivalent. So for example - you could implement a test to see if all of the integers in an array is even like this:
With reduce:
...but that's less expressive than using the 'every' method on array (not to mention the reduce and the naive loop implementation are less efficient too):
Why are they less efficient? Because we could've stopped the moment we hit an odd item because we know that the end result would be false. The every method on Array does this early out without processing the rest of the items only you don't have to think about it.
The approach I used here could've been much different. See if you can solve and improve upon it, purely functionally.
Good luck!