JavaScript Algorithms and Data Structures Projects - Cash Register

Hi, I am not used to this currency system. So either I am understanding it wrong or there is a problem. in this example, why would you return 60 bills of 20 as change for a 100 bill payment? and if that’s just sorted and not returned. then in another example, only quarters are returned? Can somebody please explain me the problem.

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

  **Your browser information:**

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

Challenge: JavaScript Algorithms and Data Structures Projects - Cash Register

Link to the challenge:

Hi Laiba, welcome to the forum.

I starred to answer but it actually is confusing me too!
Let me see if there is a known issue for this.

Edit: I couldn’t find a report of this problem already open in github.

Please open one to contribute to the correctness of the challenge.
Click on the New Issue button and put as much information as you can into the template.

Alright, I have posted. Will let you know if I get any response.

1 Like

Its just that its formatted a little odd. Its not saying return 60 different bills that all equal $20, its that there are 3 $20 bills totaling up $60 that you are giving back. Same thing for the ten dollar spot. You are not giving back 20 $10 bills, its 2 $10 bills totaling $20.

1 Like

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]]) should return {status: "OPEN", change: [["QUARTER", 0.5]]}

Then how do they return quarters in 0.5 here ? The formatting for all of them is completely different. Will that not effect the fact that my code is right or not?

Yes it will have to be returned in that same way. Since the change you will be giving back is 0.50 cents that’s what they want returned, however that will work out with the cash in the drawer from largest to smallest first.

1 Like

It doesn’t matter how weird the formatting is. They need to fix it to make it clear one way or another.

1 Like

The test tells you how it should be returned if you have the correct change.

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.

1 Like

What would you expect as an answer for that case instead? In other words - how are you understanding the task?

There are three distinct statuses (OPEN, INSUFFICIENT_FUNDS, CLOSED) requiring different returned change.

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