Quick question on cash register project

I coded (let change = cash -price )and for some odd reason im getting
1.1000000000000014 as my answer 20-18.9. I want to figure this out before I continue with the project.

  **Your code so far**
function checkCashRegister(price, cash, cid) {
let change = cash - price;
return change
let tot =[]
let toti =[]
let value = [.01,.05,.10,.25,1.00,5.00,10.00,20.00,100.00]
for(let i=0; i<value.length; i++){
  if(change /value[i] ===1){
    return value[i]
  }
  if(change / value[i]>=1){
    tot.push(value[i])
  }
  
}
  let tot1 = tot.sort((a, b) => b - a)
  for(let i =0; i<tot1.length; i++){
    if(tot1[i] + i ===change){
      toti.push(tot1[i])
      
    }

  
} 

}

console.log(checkCashRegister(18.9, 20, [["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/103.0.0.0 Safari/537.36

Challenge: Cash Register

Link to the challenge:

you saw this?

1 Like