Cash Register: why no funds?

Cash Register: why no funds?
0.0 0

#1

Working on the cash register project…
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/cash-register

I cannot understand this one:

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: []}.

The first value is the total price… and the second one the cash I’m receiving.
So the change should be 0.5 dollars, right?

The sum of all I’ve in the cash machine is more than one dollar:
[“ONE”, 1] <— just this should be enough!

Why It should return “INSUFFICIENT_FUNDS” ?
I’ve more than a dollar in the cash, and the change is 0.5!

Cannot understand :face_with_raised_eyebrow:


#2

Yes, but you should be able to return exactly 50 cents.


#3

I’ve just seen It…
don’t like it :frowning:


#4

If you can’t exactly return the amount, the customer is paying less than supposed.


#5

Don’t get It…
less than supposed?
I’ve to check if a single value or the sum of more values are exactly the change.


#6

Take the case that a customer is supposed to pay 19.50 and gives you 20.00. If you give him 1.00 back, the customer will have paid 19.00, which is less than 19.50.


#7

Understood…
Trying to figure It out.

I can’t think about an exclusive condition.
It the sum of money in the cash machine is lower than the change… It’s easy.
If It’s more, for me the cash is “OPEN”… but I should include a condition that check if, I’m “OPEN” but I cannot give the change back anyway.