Cash Register Not understanding the test cases

Tell us what’s happening:
I am not understanding the meaning of this line
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.
If the amount given back is 0.5 (20 - 19.5), that can be paid using penny, nickel or dime …
why the answer is 0.5 quarter.
we can pay the 0.5 using 100 nickel it will sum to 0.5 i.e 100 * 0.05 = 0.5
plzz help

Your code so far


function checkCashRegister(price, cash, cid) {
  var change;
  // Here is your change, ma'am.
  return change;
}

// Example cash-in-drawer array:
// [["PENNY", 1.01],
// ["NICKEL", 2.05],
// ["DIME", 3.1],
// ["QUARTER", 4.25],
// ["ONE", 90],
// ["FIVE", 55],
// ["TEN", 20],
// ["TWENTY", 60],
// ["ONE HUNDRED", 100]]

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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36.

Link to the challenge:

["QUARTER", 0.5] means that all quarters summed have a value of 0.5$

if you want to give it in nickels it is ["NICKEL", 0.5]

it is not the number of coins, it is the value of coins in that denomination

So, why the particular test return [“Quarter”, 0.5] not the [“Nickel”, 0.5] , this thing just blown my mind

it depends on how much of each is in the register before.

there are 1.01 penny, 2.05 Nickel and 3.1 Dime in the register which is greater than 0.5i.e
1.01 > 0.5 etc…

have you tried creating an algorithm for it?

If I got understand why its returning the specific answer then I will definetily create an algo for it…

it is the highest denomination with which you can give that change