Wrong boolean output

function checkCashRegister(price, cash, cid) {
  let total = 0
  let change = (cash - price).toFixed(2);

  for(let elem of cid){ total +=elem[1] }
  
  total = total.toFixed(2)
  console.log(change , total)
  console.log(change > total) // Why is this returning true
}

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]]);

toFixed returns a string, not a number.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.