Cash Register weird Output

I’m stuck with my loop…
So while looping over the conditions I implemented that cash remaining in the register is noted in two ways: cash & number of coins/notes.
so everytime the condition checks if there is still enough of the bigger currency in the register and if so it gets deducted … somehow however this doesnt work because the condition doesnt always grip ???

Here is some output – there is still TWENTY dollar bills in the register but somehow it just loops over it … for the TEN dollar bills it works …??? … same for the five dollar bills - doesnt work:

[ 'TWENTY', 40, 2 ]
160.5
[ 'TWENTY', 20, 1 ]
140.5
[ 'TEN', 10, 1 ]
130.5
[ 'TEN', 0, 0 ]
120.5
[ 'FIVE', 50, 10 ]
115.5
[ 'FIVE', 45, 9 ]
110.5
[ 'FIVE', 40, 8 ]
105.5
[ 'FIVE', 35, 7 ]
100.5
[ 'FIVE', 30, 6 ]
95.5
[ 'FIVE', 25, 5 ]
90.5
[ 'ONE', 89, 89 ]
89.5
[ 'ONE', 88, 88 ]
88.5
[ 'ONE', 87, 87 ]
87.5
[ 'ONE', 86, 86 ]
86.5
function checkCashRegister(price, cash, cid) {
  
  var price = price
  var cash = cash
  var cid = cid
  var change = cash-price;
  var toChange = change
  var totalBefore = 0
  var totalAfter = 0
   


  var currency = [["PENNY", 0.01], ["NICKEL", 0.05], ["DIME", 0.1], ["QUARTER", 0.25], ["ONE", 1], ["FIVE", 5], ["TEN", 10], ["TWENTY", 20], ["ONE HUNDRED", 100]]

  for (let i=currency.length-1;i>=0;i--){
   // currency[i][1] = Math.round(currency[i][1] * 100) / 100
    //currency[i][1] = currency[i][1].toFixed(2);
    cid[i].push(cid[i][1]/currency[i][1])
   // cid[i][1] = Math.round(cid[i][1] * 100) / 100
   // cid[i][2] = Math.round(cid[i][2] * 100) / 100
    
  }
  for (let i=0;i<cid.length;i++) {
    totalBefore += cid[i][1]
    
  }

  for (let i=currency.length-1;i>=0;i--){
   for(let j=0;j<=cid[i][2];j++){
    if (1<=toChange/currency[i][1]) {
      

      if(cid[i][2]>0){
        
        

        cid[i][2]--
        cid[i][1]-=currency[i][1]
        toChange-=currency[i][1]
        console.log(cid[i])
        console.log(toChange)
        
      }
    }}} 
    
  for (let i=0;i<cid.length;i++) {
    totalAfter += cid[i][1]
  }
  
  console.log(totalBefore+'-'+totalAfter+'=')
  console.log(totalBefore-totalAfter)
  return cid;
}


checkCashRegister(19.5, 200, [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 0]]);