Tell us what’s happening:
Hi, can anyone explain the question? what is {status: "CLOSED", change: [...]}
and {status: "OPEN", change: [...]}
supposed to show or what does that mean. what I infer from the question is that:
-
here
change
should be:change = cash - price;
-
if there is no exact
change
in the cash-register-drawer(cid
) returnreturn {status: "INSUFFICIENT_FUNDS", change: []};
For example, we may have the amount but not exact coins and bills to give like we have a $5 bill only but we need to return a quarter -
if there is no sufficient
change
in the cash-register-drawer(cid
) returnreturn {status: "INSUFFICIENT_FUNDS", change: []};
For example, we do not have the requiredchange
in coins and bills to give back, like we have to return $5 but we have a quarter only. -
here
status
key is the status of the cash register andchange
key is the amount returned to the customer. So when no amount has been returned the change key ischange:[]
and status of the cash register isstatus: "INSUFFICIENT_FUNDS",
-
{status: "OPEN", change: [...]}
would be returned when the cash-register-drawer(cid
) possessed the exact amount ofchange
to be returned in bills and coins. Herechange
would be the array of bills and coins that were returned from highest to lowest.
For example, if thechange
was $1 and the cash-register-drawer(cid
) had 6 quarters only, thechange
returned would bechange: [["QUARTER",1]]
.
What doesOPEN
represent here in this case as for thestatus
ofcid
?? -
if
change = 0
would return be `{status: OPEN", change: []} ?? -
In which case should function return
{status: "CLOSED", change: [...]}
?? what would be the meaning of statusCLOSED
forcid
and what would be returned aschange
? Please give an example of this particular case for clarity.
Please help! please verify my understanding. Thank you in advance!
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register