A possible mistake in cash register. jasa script algorithm

Tell us what’s happening:
Describe your issue in detail here.
the way i solved the problem is using the isea that you should always take the highest amout, thus making it in O(n) - n is the amount of coins you can choose. and i claimed you can do so because i thought every coin is a multiple of the smaller coins, and it worked. but i now noticed that quarter is not a multiple of dime, so ifwe have, lets say 0.3, taking a quarter might ruin it for us. if what im saying is correct, is that supposed to be so?

  **Your code so far**

function checkCashRegister(price, cash, cid) {
let 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/96.0.4664.45 Safari/537.36

Challenge: Cash Register

Link to the challenge:

That code is not a valid solution at all.

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