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.
it's not sorting properly because you didn't tell it how to sort the elements.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
compareFunction Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element.
So to correctly sort them you need to tell the sort function to compare the difference of their priorities:
lowestKey = Object.keys(this.gifts).sort((a,b)=>a.priority - b.priority)[0];
This makes sense :-) Thanks a lot.
Because Array don't have min method :-)
Bah, JS makes no sense :-) Thanks a lot for your reply.
But why Math.min.apply(Math, arr) and not just arr.min()?
You get error, because Object.keys(this.gifts).sort()[0]; not always return min. Try [3, 10, 2].sort()[0]. Use Math.min.apply(Math, arr) ;-)