# Cash Register : Need Help

Tell us what’s happening:
I’m stuck for a week. I was able to pass the challenges except for the third one and I don’t know why? Could anyone please help me and point me in the right direction?

``````
function checkCashRegister(price, cash, cid) {
var denom = [['PENNY', 0.01], ['NICKEL', 0.05], ['DIME', 0.1], ['QUARTER', 0.25], ['ONE', 1], ['FIVE', 5], ['TEN', 10], ['TWENTY', 20], ['ONE HUNDRED', 100]];
var output = {"status": '', "change": []};
var change = cash - price;
// Here is your change, ma'am.

//Value of Cash-in-drawer
var cidTotal = cid.reduce( function (acc, curr) {
return acc + curr[1];
}, 0);
cidTotal = Math.round(cidTotal * 100) / 100;

//results
if(cidTotal < change) {
output.status +=  'INSUFFICIENT_FUNDS';
return output;
}
if(cidTotal === change) {
output.status += 'CLOSED';
output.change = cid;
return output;
}

//breakup of change
var changeArr = [];

for (var i = cid.length - 1; i > 0; i--) {
var value = 0;
while(change >= denom[i][1] && value < cid[i][1]) {
change -= denom[i][1];
value += denom[i][1];
change = Math.round(change * 100)/100;
}
if(value > 0){
changeArr.push([denom[i][0], value]);
}
value = 0;
}
if(change > 0){
output.status +=  'INSUFFICIENT_FUNDS';
return output;
}
output.status += 'OPEN';
output.change = changeArr;
return output;
}

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]]);
``````

User Agent is: `Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36`.

The problem is that you don’t give out pennies.

``````for (var i = cid.length - 1; i > 0; i--) {
``````

You end the `for` loop when `i` is `1`, but pennies are `cid[0]`.

Thank you so much. I’ve overlooked this one.

I’m glad I could help. Happy coding!

1 Like