JavaScript Algorithms and Data Structures Projects - Cash Register

Tell us what’s happening:
Describe your issue in detail here.
the third test is not passing despite a lot of rechecking. Its very fustrating

   **Your code so far**
function checkCashRegister(price, cash, cid) {
let change = cash*100 - price*100;
let cidTotal = 0
for (let elem of cid) {
cidTotal += elem[1]*100
}
if (change > cidTotal) {
 return {status: "INSUFFICIENT_FUNDS", change: []};
} else if (change === cidTotal) {
 return  {status: "CLOSED", change: cid}
} else {
 let answer = []
 cid = cid.reverse();
 let currencyUnit = {
 "PENNY": 1,
 "NICKEL": 5,
 "DIME": 10,
 "QUARTER": 25,
 "DOLLAR": 100,
 "FIVE DOLLARS": 500,
 "TEN DOLLARS": 1000,
 "TWENTY DOLLARS": 2000,
 "ONE HUNDRED DOLLARS": 10000,
};
 for (let elem of cid) {
   let holder = [elem[0], 0]
elem[1] = elem[1]*100
while (change >= currencyUnit[elem[0]] && elem[1] > 0) {
change -= currencyUnit[elem[0]]
elem[1] -= currencyUnit[elem[0]]
holder[1] += currencyUnit[elem[0]]/100 
 } if (holder[1]>0) {
   answer.push(holder)
 }
}
if (change > 0) {
   return {status: "INSUFFICIENT_FUNDS", change: []}; 
   }
   return {status: "OPEN", change: answer}
 } 
}



console.log(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/104.0.0.0 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Cash Register

Link to the challenge:

This is a bad idea

you should do this only after you have finished calculating.

I have added a console.log statement right before your return

console.log({change, answer})

and I get this

{ change: 8633,
  answer: 
   [ [ 'QUARTER', 4.25 ],
     [ 'DIME', 3.1000000000000014 ],
     [ 'NICKEL', 2.0500000000000007 ],
     [ 'PENNY', 1.0100000000000007 ] ] }

that means you still have a lot of change you have not given back! and you have lost precion in your numbers

Another thing to consider is:

 let currencyUnit = {
 "PENNY": 1,
 "NICKEL": 5,
 "DIME": 10,
 "QUARTER": 25,
 "DOLLAR": 100,
 "FIVE DOLLARS": 500,
 "TEN DOLLARS": 1000,
 "TWENTY DOLLARS": 2000,
 "ONE HUNDRED DOLLARS": 10000,
};

Are you sure those are the right property names?