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.
Try using console.log(arr) to see what is getting passed to the test values. You may have to account for unexpected types of input.
Try using console.log(arr) to see what is getting inserted into each test. The results might be surprising. ;-)
I now realize the || statements were totally unnecessary and submitted a refactored version... ;)
Got it - that helped. thanks!
It has to do with the way that functions are called. If you substitue the addOne(3) with the value assigned to it, you get:
var addOne = add(1); addOne(3) equals add(1)(3);
So the call passes the arguments in the set order.
this assumes that there should be exacly 1 occurrence of each number always. the kata description doesn't say that just that it needs to have all elements from 0 to 9.
Agree. I am going through every single 7kyu exercise right now and this one is excessively more difficult than any other I've tried so far. At least 6kyu. Maybe 5, although I wouldn't know because I haven't done any 5s yet...
This comment is hidden because it contains spoiler information about the solution
Ah now it makes perfect sense. Thanks!!
The reduce function just takes a collection of values and returns a single value out the end, depending on the function you provide on the inside. In a nut shell, it starts out with what the answer should be, and subtracts the values that are given. In then end, the missing value is what is popped out the other end of the reduce.
This solution looks quite clever; I wish I understood it! Can someone explain to me how it works? I sort of understand how reduce works and see the sum of the array is 45, but I still seem to be fuzzy on what is going on with these types of solution.