**Tell us what’s happening:**

Anybody is able to spot the bug? I have been trying for a few days now with some refactoring also to no avail… thanks.

**Your code so far**

```
function checkCashRegister(price, cash, cid) {
let result = { status: "", change: [cid] };
let changeDue = parseFloat(cash - price).toFixed(2);
let changeAvailable = getChangeAvailable(cid);
result.status = getRegisterStatus(changeDue, changeAvailable);
if (changeDue < 0) return "Cash not sufficient ma'am!";
if (result.status === "INSUFFICIENT_FUNDS") {
result.change = [];
return result;
}
result.change = getCustomerChange(changeDue, cid);
return result;
}
function getChangeAvailable(changeInDrawer) {
let total = 0;
let length = changeInDrawer.length;
for (let i = 0; i < length; i++) {
total += changeInDrawer[i][1];
}
return total.toFixed(2);
}
function getRegisterStatus(changeDue, changeAvailable) {
if (changeDue > changeAvailable) {
return "INSUFFICIENT_FUNDS";
}
if (changeDue < changeAvailable) {
return "OPEN";
}
return "CLOSED";
}
function getCustomerChange(changeDue, changeInDrawer) {
const change = [];
const units = [
["PENNY", 0.01],
["NICKEL", 0.05],
["DIME", 0.1],
["QUARTER", 0.25],
["ONE", 1.0],
["FIVE", 5.0],
["TEN", 10.0],
["TWENTY", 20.0],
["ONE HUNDRED", 100.0],
];
const length = changeInDrawer.length;
for (let i = length - 1; i >= 0; i--) {
const currencyName = changeInDrawer[i][0];
const currencyTotalAvailable = changeInDrawer[i][1];
const currencyUnitValue = units[i][1];
let currencyAmountAvailable = (
currencyTotalAvailable / currencyUnitValue
).toFixed(0);
let currencyToReturn = 0;
while (changeDue >= currencyUnitValue && currencyAmountAvailable > 0) {
changeDue -= currencyUnitValue;
changeDue = changeDue.toFixed(2);
currencyAmountAvailable--;
currencyToReturn++;
}
if (currencyToReturn > 0) {
change.push([currencyName, currencyToReturn * currencyUnitValue]);
}
}
return change;
}
```

**Your browser information:**

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

.

**Challenge:** Cash Register

**Link to the challenge:**