Help with Exact Change challenge

Help with Exact Change challenge


I feel like my code should be passing but it is not. For example:
My code returns: [[“QUARTER” ,0.5]]
FCC says it should return: [[“QUARTER”, 0.50]]
Why isn’t it passing?

(I know my code if FAR from ideal)


I went to your gist, copied your code and tried running it. I got a reference error for an undefined variable index somewhere. Frankly, that’s way too much code for me to debug, but should send you in the right direction. The trailing 0 won’t matter.


As PortableStick said, the issue isn’t the trailing 0, I double checked and mine passed with “0.5”. You can get your output to show as “0.50” by using .toFixed(2). the problem is that this converts it to a string, so it wont pass this challenge.

The index error PortableStick pointed out is on line 139, I am assuming you already fixed this if you were getting the output above, but it should be replaced with cid[3][1] -= 0.25;

Unfortunately, I can’t figure out why it still doesn’t pass after making that change, but it still fails both of the change output tests even though the output appears to match…
Your Output for test 5:
My Output for test 5:

Yours fails, mine passes. I honestly don’t know why and the same thing happens for test 4, all other tests pass. I’ll try to take a better look this evening if I have some time.


I figured it out.

It turns out that other than that index your code is fine (as in correct :P)
now all you have to do is cut
function checkCashRegister(price, cash, cid) {
and plaster it on top of the page, the very first row
that should fix it