I have satisfied the first 4 test cases, but the last two i have questions about how/what exactly they are testing for. The last test case is looking for:

{status: “CLOSED”, change: [[“PENNY”, 0.5], [“NICKEL”, 0], [“DIME”, 0], [“QUARTER”, 0], [“ONE”, 0], [“FIVE”, 0], [“TEN”, 0], [“TWENTY”, 0], [“ONE HUNDRED”, 0]]}

My return is: { status: ‘CLOSED’, change: [ [ ‘PENNY’, 0.5 ] ] }

I see the expected return is including all the empty values, HUNDRED, TWENTY etc. Is this why I am not satisfying this test case? This reason wouldn’t really make sense to me bc there is two similar passed test cases that had expected results that did not include the empty values:

{status: “OPEN”, change: [[“QUARTER”, 0.5]]}

{status: “OPEN”, change: [[“TWENTY”, 60], [“TEN”, 20], [“FIVE”, 15], [“ONE”, 1], [“QUARTER”, 0.5], [“DIME”, 0.2], [“PENNY”, 0.04]]}

My second question is on the other test case which I am not satisfying.

`checkCashRegister(19.5, 20, [["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]])`

should return `{status: "INSUFFICIENT_FUNDS", change: []}`

The change due is .50 (20 - 19.50) and the drawer total is 1.01 ( [“ONE”, 1] + [“PENNY”, 0.01] ). The expected return is “INSUFFICIENT_FUNDS”. There is enough money in this drawer to satisfy giving the customer change and still having an “OPEN” status. My code checks to see if the change to be returned is greater than the drawer total. If change is greater, the “INSUFFICIENT_FUNDS” status is set. It could never do that with this test case because there is enough money in the drawer to give the customer change. Am I missing something?

I understand no help will be given on final projects which i fully agree with. I am just looking for test case clarification.

Thanks

```
function checkCashRegister(purchPrice, payment, cid) {
let drawer = cid.slice().reverse()
let drawerTotal = 0
let change = payment - purchPrice
let key = [[100, 0], [20, 0], [10, 0], [5, 0], [1, 0], [.25, 0], [.1, 0], [.05, 0], [.01, 0]]
let final = {status: "OPEN", change: []}
//Calculates drawer total
for(let i = 0; i < drawer.length; i++){
drawerTotal += drawer[i][1]
}
//Status
if(change > drawerTotal){
return {status: "INSUFFICIENT_FUNDS", change: []}
}
else if(change === drawerTotal){
final.status = "CLOSED"
}
//Calculates key
for(let i = 0; i < drawer.length; i++){
key.push([key[i-i][0], drawer[i][1]]);
key.shift()
}
//return
for(let i = 0; i < key.length; i++){
let total = 0
while(change >= key[i][0] && drawer[i][1] !== 0){
change = Math.round(change * 100) / 100
total += key[i][0]
change -= key[i][0]
drawer[i][1] -= key[i][0]
drawerTotal -= key[i][0]
change = Math.round(change * 100) / 100
}
if(total != 0){
final.change.push([drawer[i][0], Math.round(total * 100) / 100])
}
}
return final
}
console.log(checkCashRegister(19.5, 20, [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]))
```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36`

**Challenge:** JavaScript Algorithms and Data Structures Projects - Cash Register

**Link to the challenge:**