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.
Hi.
I think you can add another test, because my script has passed when it shouldn't.
If you try this:
var vm = new VendingMachine({1:0, 3:2, 5:1, 8:0});
vm.vending(9, {8:2});
As the price is 9 and I put 16 coins (8x2), the machine should return a change of 7, but it hasn't enough coins for that. According to the description, the machine should return the closest value to the expected change. In this case the closest value is 6 (3x2).
As I mentioned, my script has passed the test cases, but if you try the example above, you'll see my script returns a change of 5 (5x1), so I suppose you can add a test case like this to ensure the scripts are well-constructed.
Of course, I will improve my solution to pass this kind of test too.