Better Grasp of Understanding
AngelaThomas2 (3)

I have been meeting some difficulty with the lines of code on this repl: .

When I run the code, it says I am passing half of what is expected, but failing on returning {} when called with []. Why might I be getting this error and how can I solve it out? I have gone back through this scenario and its entirety and can't find the missing piece of this puzzle.

You are viewing a single comment. View All
malvoliothegood (709)

@AngelaThomas2 I have had a look at your latest code and it doesn't really make sense. What is the allCandyOrders function meant to do? I.e. what written instructions have you been given? I am thinking that you don't really understand what is going on.

From the function's name, allCandyOrders, and the fact that it has a parameter called inventory I am surmising that it takes in an inventory and returns the items in it that are candies. Instead you have hard-coded and returned an object that does not have the same keys that your inventory object in index.js has. Presumably you have done this so it will pass the test.

It is also confusing that you have two inventory arrays, one in each file.

test(allCandyOrders([]), {}, '[]') is failing because allCandyOrders returns the object that you have hard-coded in no matter what argument you pass into it. Therefore the comparison that the test function does is between this object and an empty object, so of course it fails. For the test to pass both the value that allCandyOrders returns and the value you are testing have to be the same in regards to the key names. The values each key has do not matter so much.

I hope this feedback has been of help to you.