I think there's a MISTAKE on one of the TESTS

Tell us what’s happening:
So I was working on the cash register code and all but one tests have passed.

The instructions were:

Design a cash register drawer function checkCashRegister() that accepts purchase price as the first argument ( price ), payment as the second argument ( cash ), and cash-in-drawer ( cid ) as the third argument.

Return {status: "INSUFFICIENT_FUNDS", change: []} if cash-in-drawer is less than the change due, or if you cannot return the exact change.
Return {status: "CLOSED", change: [...]} with cash-in-drawer as the value for the key change if it is equal to the change due.

Otherwise, return {status: "OPEN", change: [...]} , with the change due in coins and bills, sorted in highest to lowest order, as the value of the change key.

And the test says:

checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]) should return {status: "INSUFFICIENT_FUNDS", change: []} .

But if you look closely there’s $1.01 in the cash register and only $0.05 change is needed, so why must the return be “INSUFFICIENT FUNDS”?

   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36

Challenge: Cash Register

Link to the challenge:

Hi!
The cash register is the amount that you have in your hand at that moment.
If a customer where to give you $20 for a $19.5 item, what would you do?
In this case, you have only ONE $1 note and A Penny ($0.01) .

Do you have the amount to pay back the exact balance, that is $0.5?

The goal here is to pay back the correct or , exact balance accordingly.
If you pay $1, that would be a loss since you lose $0.5. If you pay less , that would be illegal. Since you dont have any other currency to pay the correct balance, the program asks you to return INSUFFICIENT_FUNDS.

Hope this helped.

Ooooh! I totally get it now, thank you!
You can’t physically separate the $1 note into $0.05 in real life like you can on a computer.

2 Likes

The government doesn’t take kindly to cutting a physical $1 bill into 100 pieces and saying they are pennies :slight_smile:

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.