I just completed the project “Cash Register” in the JavaScript Algorithms and Data Structures Projects for the JavaScript Algorithms and Data Structures certification and encountered an error on this test: 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]]).
The problem should be obvious in these expected results: {status: “OPEN”, change: [[“TWENTY”, 60], [“TEN”, 20], [“FIVE”, 15], [“ONE”, 1], [“QUARTER”, 0.5], [“DIME”, 0.2], [“PENNY”, 0.04]]}. To clarify, the expected results for “change” are in the reverse order of the expected results for all other tests. This is to say that these expected results start with the largest denomination, while all other tests start with the smallest denomination. I was able to write an IF statement to accommodate this one test and finish the project, but this is an easy error to fix, so I hope somebody will update it!
Thanks
This is intended, per the problem spec:
Return
{status: "CLOSED", change: [...]}
with cash-in-drawer as the value for the keychange
if it is equal to the change due.
Otherwise, return
{status: "OPEN", change: [...]}
, with the change due in coins and bills, sorted in highest to lowest order, as the value of thechange
key.
hi there,
I really don’t view that as an error, that was really intended and logical even in the real world. You just have to read through the problem carefully and analyze; I had a difficult time solving this project as well, but in the end, the rest is really about data manipulation regardless what methods you employ to solve the challenge.
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.