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.
Peter Parker
Very nice but it returns Infinity for empty recipe list. The reduce() method does not execute the function for empty array elements.
I think this is an underrated concern...
But isnt this for a recipe calculation? There's never going to be 100k + ingredients to compare, or whatever you would need for that to make a difference?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Umm... can anyone explain this solution to me. Srry Im not that sharp hahahahah.
god。。。
Well that killed my code.......
length thing will not work, example the recipe does not have milk, but the available obj does. And I don't think it would be best practice to assume that wouldn't happen, though I don't know if that is true or not.
Cool solution!
After several minutes trying to understand this solution I finally got it. Can't believe its simplicity!
hahaha, you could also reduce it more with
let t = this
xDperfect
Easier to read than mine for sure. Kudos! I did write some test cases that caused it to fail though. Not sure if these edge cases are worth handling for a Kata. Testing is in my blood. I'm thinking { mush: 0, apples: 3 }, { apples: 7, mush: 0 } should return 2, { apples: null, mush: 1 }, { mush: 1, apples: 0 } should return 1 and { apples: -1, mush: 1 }, { mush: 1, apples: Infinity } should return 1.
Loading more items...