Hi all,

I know the code below is probably really bad but I am hoping you can explain why Iam failing the 3rd test down, all the others are passing, and as far as I can I see with console.log() the output is what the test wants.

```
function checkCashRegister(price, cash, cid) {
let change = {status: "", change: []}
let sum = cash-price
const value = [0.01,0.05,0.1,0.25,1,5,10,20,100]
let cidTotalValue = cid.reduce((total,cidValue)=> total + cidValue[1] ,0)
let cid2 = cid.map(x=> x[1])
let total = [0,0,0,0,0,0,0,0,0]
let check = Math.round(sum * 100)/100
let i = 8
num(sum,cid2,value)
function num(sum,cid2,value){
if(i<0){
}
if(cid2[i]>0 && check-value[i]>=0){
total[i] +=value[i]
check-=value[i]
cid2[i]-=value[i]
check = (Math.round(check * 100)/100)
total[i] = (Math.round(total[i] * 100)/100)
num(sum,cid2,value)
}
else if(i>0){
i--
num(sum,cid2,value)
}
}
let totalValue = total.reduce((total,value)=> total+value )
console.log(totalValue,total,sum)
inject(sum)
function inject(sum){
if(cidTotalValue==sum){
change.status = "CLOSED"
change.change = cid
} else if(totalValue<sum){
change.status = "INSUFFICIENT_FUNDS"
change.change = []
} else if(totalValue==sum){
change.status = "OPEN"
}
for(let i in total){
if (total[i] >0 && totalValue==sum && change.status != "CLOSED" ) {
change.change.push([cid[i][0], total[i]])}
}
}
console.log(change)
}
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]]);
```

```
**Your browser information:**
```

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

.

**Challenge:** Cash Register

**Link to the challenge:**