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 keychangeif 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 thechangekey.
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:
