I need assistance with my code for the Cash Register:

Here is my code:

let price = 3.26;
let cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["ONE HUNDRED", 100]
];


// Set Up Constants
const cash = document.getElementById("cash");
const displayChangeDue = document.getElementById("change-due");
const purchaseBtn = document.getElementById("purchase-btn");
const cashDrawerDisplay = document.getElementById("cash-drawer-display");
const priceScreen = document.getElementById("price-screen");


/* Function to Format Results */
function formatResults(status,change) {
  displayChangeDue.innerHTML = `<p>Status: ${status}</p>`;
  change.map(money => (displayChangeDue.innerHTML += `<p>${money[0]}: $${money[1]}</p>`));
  return;
}

/* Function to Check Results */
function checkResults() {
  if (!cash.value) return;
  checkCashRegister();
}

/* Function to Check Cash Register */
function checkCashRegister() {
  if (Number(cash.value) < price) {
    alert("Customer does not have enough money to purchase the item");
    cash.value = '';
      return;
  }

  if (Number(cash.value) === price) {
    displayChangeDue.innerHTML = `<p>No change due - customer paid with exact cash</p>`;
    cash.value = '';
    return;
  }

  let changeDue = Number(cash.value) - price;

  let reversedCid = [...cid].reverse();
  let denominations = [100,20,10,5,1,0.25,0.1,0.05,0.01];
  let result = {status: "OPEN", change: []};
  let totalCID = parseFloat(cid.map(total => total[1]).reduce((p,c) => p+c,0).toFixed(2));

  if (totalCID < changeDue) return displayChangeDue.innerHTML = `<p>Status: INSUFFICIENT_FUNDS</p>`;

  if (totalCID === changeDue) result.status = "CLOSED";

  for (let i=0;i<=reversedCid.length;i++) {
    if (changeDue > denominations[i] && changeDue > 0) {
      let count = 0;
      let total = reversedCid[i][1];
      while (total>0 && changeDue >= denominations[i]) {
        total -= denominations[i];
        changeDue = parseFloat((changeDue -= denominations[i]).toFixed(2));
        count++;
             }       
             if (count > 0) result.change.push([reversedCid[i][0], count * denominations[i]]);

      }
  }
if (changeDue > 0) return (displayChangeDue.innerHTML = `<p>Status: INSUFFICIENT_FUNDS</p>`);
formatResults(result.status,result.change);
updateUI(result.change);

}

/* Function to Update UI */
function updateUI(change) {
  const currencyNameMap = {
    PENNY: 'Pennies',
    NICKEL: 'Nickels',
    DIME: 'Dimes',
    QUARTER: 'Quarters',
    ONE: 'Ones',
    FIVE: 'Fives',
    TEN: 'Tens',
    TWENTY: 'Twenties',
    'ONE HUNDRED':'Hundreds'
  };

  if (change) {
    change.forEach(changeArr => {
      const targetArr = cid.find(cidArr => cidArr[0] === changeArr[0]);
      targetArr[1] = parseFloat((targetArr[1] - changeArr[1]).toFixed(2));
    });
  }

  cash.value = '';
  priceScreen.textContent = `Total: $${price}`;
  cashDrawerDisplay.innerHTML = `<p><strong>Change in drawer:</strong></p>${cid.map(money => `<p>${currencyNameMap[money[0]]}: $${money[1]}</p>`).join('')}`;

}

// Apply Event Listeners
purchaseBtn.addEventListener('click',checkResults);

cash.addEventListener('keydown', (e) => {
  if (e.key === "Enter") checkResults();
});

updateUI();

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.