JavaScript Algorithms and Data Structures Projects - Palindrome Checker - _R8O3aA9cKquq7vx05c3T

Tell us what’s happening:
I am working on the last challenge of the javascript course and I need some guidance. So far I have converted, calculated what is due, and returning the result. Where I am stuck is how to do the change calculation. If someone could lead me in the right direction that would be awesome.

  **Your code so far**
function checkCashRegister(price, cash, cid) {
  let owed = cash - price
  let amountOfEach = [
    ["PENNY", 0.01],
    ["NICKEL", 0.05],
    ["DIME", 0.1],
    ["QUARTER", 0.25],
    ["ONE", 1], 
    ["FIVE", 5], 
    ["TEN", 10], 
    ["TWENTY", 20], 
    ["ONE HUNDRED", 100]
  ]
  let due = 0
  let converted = []
  for (let i = 0; i < cid.length; i++) {
    if (cid[i][0] === amountOfEach[i][0]) {
      let x = cid[i][1] / amountOfEach[i][1] 
      converted.push(cid[i][0], x)
      due += x
    }
  }
  if (owed > due) {
    return {status: "INSUFFICIENT_FUNDS", change: []}
  } else if  (owed === due) {
    return {status: "CLOSED", change: [cid]}
  } else {
    return {status: "OPEN", change: []}
  }
}

checkCashRegister(19.5, 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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Link to the challenge:

Are you talking about the floating point numbers? There are a couple ways. I prefer changing them to integers and doing doing the math that way.

Hello. You may wanna to edit name of the thread: I guess you are talking about Cash Register project, not Palindrome Checker.