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.
If the recipe is blank it is logically perfectly correct to return Infinity (or whatever, in fact).
We can add this at the first line: if (Object.keys(recipe).length === 0) return 0;
It will save us from empty recipe.
In the rest this solution seems to be the best practice.
If the recipe is blank, you return Infinity. You don't provide for breaking the loop as soon as you know you can produce 0 of the recipe. There are two cases where that can happen.