What to do with args

Tell us what’s happening:
Describe your issue in detail here.

Hi, please, help me understand, what i need to do.
I don’t understand this challenge and what my function should do, i see no sense in what it should returns, help me understand in simple words please. If i understand what it should do with argumentsБ i will write algorithm… but now i can’t

  **Your code so far**

function checkCashRegister(price, cash, cid) {
let b = price - cash;

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/95.0.4638.69 Safari/537.36 OPR/81.0.4196.61

Challenge: Cash Register

Link to the challenge:

The aim is to implement a cash counter.

consider you are the cashier at a shop. Some one bought things worth 48 bucks and they gave you 50 bucks as cash. Now you have to return the balance which is 2 bucks. Now you have to check in the drawer for the balance.

This is the scenario

function checkCashRegister(price, cash, cid) {
let b = price - cash;

Now consider the arguments

  1. price - the price of what the customer bought, which is 48 in the example mentioned above

  2. cash - the cash the customer given to you - 50 bucks

  3. cid - cash drawer itself - for example

 [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25]]

here you have pennies worth 1.01, nickel worth 2.05 …etc in the drawer

now you have to implement a function that will check the cash drawer and give the balance and update the drawer.

Thats all

1 Like

but what is second arg in the answer ([quarter, 0,5]), why it is not equal to 4.25, what quarter really is.

already thank you for your last answer^^

because to give change to a guy coming in with $19.5 worth of items, and a $20 bill, you would give him $0.5 (two quarters) back.

To return an answer of [quarter,4.25] would be like saying since the customer needs change in quarters, I will give him all the quarters in my register.

1 Like

ooo, i thought that 4.25 is value of quarter, not amount… thank you very much, i understand now!!!

1 Like

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