Need some clarification regarding output

How we get to this output ?
checkCashRegister(3.26, 100, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]) should return {status: "OPEN", change: [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]}

if we do 100-3.26 we get $96.74, why we are returning twenty , 60 ?

  **Your code so far**

function checkCashRegister(price, cash, cid) {
var change;
return change;

checkCashRegister(19.5, 20, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]);
  **Your browser information:**

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

Challenge: Cash Register

Link to the challenge:

That’s not what you’re returning. That is the amount of twenties in the cash register, namely, 3 twenties == 60 dollars total.

Much like a cash register in real life, when change is given out, they don’t give you a piece of paper saying it’s worth “$96.74”, but give you cash of various denominations that combine to that change value.

Here in the test case you can see an array named change is returned, which has the value of [["TWENTY", 60], ["TEN", 20], ["FIVE", 15], ["ONE", 1], ["QUARTER", 0.5], ["DIME", 0.2], ["PENNY", 0.04]]. With each subarray describing the type of bill given at index 0, and the amount of money in that denomination at index 1.

e.g. [“TWENTY”,60] means cashier has given you $60 in twenties.

So adding every value up in that array: 60+20+15+1+0.5+0.2+0.04=$96.74

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