Build a Cash Register Project - Build a Cash Register

Tell us what’s happening:

I’m physically changing each number in cid variable to test out each problem, and it passes just fine. Im wondering why it is not passing it normally.

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

const changeDue = document.getElementById('change-due');
const childc = document.getElementById('childcontainer');
const btn = document.getElementById('purchase-btn');
const inpt = document.getElementById('cash');


let price = 19.5;
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]
];

let copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
}
const keys = Object.keys(copy);


const reset = () => {
  copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
};
  cid = [
  ["PENNY", 1.01],
  ["NICKEL", 2.05],
  ["DIME", 3.1],
  ["QUARTER", 4.25],
  ["ONE", 90],
  ["FIVE", 55],
  ["TEN", 20],
  ["TWENTY", 60],
  ["ONE HUNDRED", 100]
];
  inpt.value = '';
}

window.addEventListener("load", (event) => {
  childc.insertAdjacentHTML('beforeend', `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1]}<br>Nickels: ${cid[1][1]}<br>Dimes: ${cid[2][1]}<br>Quarters: ${cid[3][1]}<br>Ones: ${cid[4][1]}<br>Fives: ${cid[5][1]}<br>Tens: ${cid[6][1]}<br>Twenties: ${cid[7][1]}<br>Hundreds: ${cid[8][1]}</p>`);
});
const conversion = (input) => {
  reset();
  if (input < price) {
    alert('Customer does not have enough money to purchase the item');
    return;
  }  
  if (input === price) {
    changeDue.textContent = "No change due - customer paid with exact cash";
    return;
  }
  
  if (input > cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1]) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  }
  input -= price;
  while (input > 0) {
    while (input >= 100 && cid[8][1] > 0) {
      cid[8][1] -= 100;
      input -= 100;
      copy['ONE HUNDRED'] += 100;
      if (cid[8][1] === 0 || input < 100) {
        break;
      }
    }
    while (input >= 20 && input < 100 && cid[7][1] > 0 || cid[8][1] === 0 && input >= 20 && cid[7][1] > 0 ) {
      cid[7][1] -= 20;
      input -= 20;
      copy.TWENTY += 20;
      if (cid[7][1] === 0 || input < 20) {
        break;
      } 
    }
    while (input >= 10 && input < 20 && cid[6][1] > 0 || cid[7][1] === 0 && input >= 10 && cid[6][1] > 0 ) {
      cid[6][1] -= 10;
      input -= 10;
      copy.TEN += 10;
     if (cid[6][1] === 0 || input < 10) {
       break;
     } 
    }
    while (input >= 5 && input < 10 && cid[5][1] > 0 || cid[6][1] === 0 && input >= 5  && cid[5][1] > 0 ) {
      cid[5][1] -= 5
      input -= 5;
      copy.FIVE += 5;
     if (cid[5][1] === 0 || input < 5) {
       break;
     }
    }
    while ( input >= 1 && input < 5 && cid[4][1] > 0 || cid[5][1] === 0 && input >= 1 && cid[4][1] > 0) { 
      cid[4][1] -= 1;
      input -= 1;
      copy.ONE += 1;
     if (cid[4][1] === 0 || input < 1) {
       break;
     } 
    }
    while (input >= 0.25 && input < 1 && cid[3][1] > 0 || cid[4][1] === 0 && input >= 0.25 && cid[3][1] > 0) {
      cid[3][1] -= 0.25;
      input -= 0.25;
      copy.QUARTER += 0.25;
     if (cid[3][1] === 0 || input < 0.25) {
       break;
     } 
    }
    while (input >= 0.10 && input < 0.25 && cid[2][1] > 0 || cid[3][1] === 0 && input >= 0.10 && cid[2][1] > 0) {
      cid[2][1] -= 0.10;
      input -= 0.10;
      copy.DIME += 0.10;
     if (cid[2][1] === 0 || input < 0.10) {
       break;
     }
    }
    while (input >= 0.05 && input < 0.10 && cid[1][1] > 0 || cid[2][1] === 0 && input >= 0.05 && cid[1][1] > 0) {
      cid[1][1] -= 0.05;
      input -= 0.05;
      copy.NICKEL += 0.05;
     if (cid[1][1] === 0 || input < 0.05) {
       break;
     } 
    }
    while (input > 0 && input < 0.05 && cid[0][1] > 0 || cid[1][1] === 0 && input > 0 && cid[0][1] > 0) {
      cid[0][1] -= 0.01;
      input -= 0.01;
      copy.PENNY += 0.01;
     if (cid[0][1] === 0 || input === 0) {
       break;
     }
    }
   if (input === 0) {
     break;
   }
  }
  if (cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1] > copy["ONE HUNDRED"] + copy.TWENTY + copy.TEN + copy.FIVE + copy.ONE + copy.QUARTER + copy.DIME + copy.NICKEL + copy.PENNY) {
    changeDue.textContent = 'Status: OPEN ';
    keys.sort((a, b) => copy[b] - copy[a]);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${copy[key]} `;
      }
   });
  } else {
    changeDue.textContent = 'Status: CLOSED ';
    keys.sort((a, b) => copy[b] - copy[a]);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
      changeDue.textContent += `${key}: $${copy[key]} `;
      }
    });
  }
  
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1]}<br>Nickels: ${cid[1][1]}<br>Dimes: ${cid[2][1]}<br>Quarters: ${cid[3][1]}<br>Ones: ${cid[4][1]}<br>Fives: ${cid[5][1]}<br>Tens: ${cid[6][1]}<br>Twenties: ${cid[7][1]}<br>Hundreds: ${cid[8][1]}</p>`; 
 }

btn.addEventListener('click', function () {
  conversion(inpt.value);
});



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Build a Cash Register Project - Build a Cash Register

Please share your HTML and CSS as well, it’s necessary (well, HTML is) to fully reproduce the working code.

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link href="styles.css" rel="stylesheet"> 
    <title>Register</title>
  </head>
  <body>
    <div id="parentcontainer">
      <h1>Cash Register</h1>
      <div id="change-due"></div>
      <div id="firstchild"><label for="cash">Enter Cash From Customer:</label> <input id="cash" type="number" required></input>
      <button id="purchase-btn">Purchase</button></div>
      <div id="childcontainer">
       
      </div>
    </div>
  <script src="script.js"></script>
  </body>
</html>

// css 
#change-due {
  width: 300px;
  height: 100px;
}
      ```

Hmm, could you explain how reset function is supposed to work when processing transactions?

Hello so played around a bit and fixed a bit of my code. managed to pass all the tests except the last one… im not sure how to go about doing it. the rest function resets the cash in draw and change values back to previous amounts prior to transaction each time the purchase button is clicked.

here is my updated JS

const changeDue = document.getElementById('change-due');
const childc = document.getElementById('childcontainer');
const btn = document.getElementById('purchase-btn');
const inpt = document.getElementById('cash');


let price = 19.5;
let cid = [
  ["PENNY", 0.5],
  ["NICKEL", 12],
  ["DIME", 32],
  ["QUARTER", 23],
  ["ONE", 23],
  ["FIVE", 23],
  ["TEN", 32],
  ["TWENTY", 22],
  ["ONE HUNDRED", 12]
];


let copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
}
const keys = Object.keys(copy);


function reset () {
  copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
}
cid = [
  ["PENNY", 0.5],
  ["NICKEL", 12],
  ["DIME", 32],
  ["QUARTER", 23],
  ["ONE", 23],
  ["FIVE", 23],
  ["TEN", 32],
  ["TWENTY", 22],
  ["ONE HUNDRED", 12]
];
  inpt.value = '';
}

window.addEventListener("load", (event) => {
  childc.insertAdjacentHTML('beforeend', `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1]}<br>Nickels: ${cid[1][1]}<br>Dimes: ${cid[2][1]}<br>Quarters: ${cid[3][1]}<br>Ones: ${cid[4][1]}<br>Fives: ${cid[5][1]}<br>Tens: ${cid[6][1]}<br>Twenties: ${cid[7][1]}<br>Hundreds: ${cid[8][1]}</p>`);
});
const conversion = (input) => {
  
  if (input < price) {
    alert('Customer does not have enough money to purchase the item');
    return;
  }  
 if (Math.abs(input - price) < 0.0001) {
  changeDue.textContent = "No change due - customer paid with exact cash";
  return;
} 
  
  if (input > cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1]) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  }
  input -= price;
  while (input > 0) {
    while (input >= 100 && cid[8][1] > 0) {
      cid[8][1] -= 100;
      input -= 100;
      copy['ONE HUNDRED'] += 100;
      if (cid[8][1] === 0 || input < 100) {
        break;
      }
    }
    while (input >= 20 && input < 100 && cid[7][1] > 0 || cid[8][1] === 0 && input >= 20 && cid[7][1] > 0 ) {
      cid[7][1] -= 20;
      input -= 20;
      copy.TWENTY += 20;
      if (cid[7][1] === 0 || input < 20) {
        break;
      } 
    }
    while (input >= 10 && input < 20 && cid[6][1] > 0 || cid[7][1] === 0 && input >= 10 && cid[6][1] > 0 ) {
      cid[6][1] -= 10;
      input -= 10;
      copy.TEN += 10;
     if (cid[6][1] === 0 || input < 10) {
       break;
     } 
    }
    while (input >= 5 && input < 10 && cid[5][1] > 0 || cid[6][1] === 0 && input >= 5  && cid[5][1] > 0 ) {
      cid[5][1] -= 5
      input -= 5;
      copy.FIVE += 5;
     if (cid[5][1] === 0 || input < 5) {
       break;
     }
    }
    while ( input >= 1 && input < 5 && cid[4][1] > 0 || cid[5][1] === 0 && input >= 1 && cid[4][1] > 0) { 
      cid[4][1] -= 1;
      input -= 1;
      copy.ONE += 1;
     if (cid[4][1] === 0 || input < 1) {
       break;
     } 
    }
    while (input >= 0.25 && input < 1 && cid[3][1] > 0 || cid[4][1] === 0 && input >= 0.25 && cid[3][1] > 0) {
      cid[3][1] -= 0.25;
      input -= 0.25;
      copy.QUARTER += 0.25;
     if (cid[3][1] === 0 || input < 0.25) {
       break;
     } 
    }
    while (input >= 0.10 && input < 0.25 && cid[2][1] > 0 || cid[3][1] === 0 && input >= 0.10 && cid[2][1] > 0) {
      cid[2][1] -= 0.10;
      input -= 0.10;
      copy.DIME += 0.10;
     if (cid[2][1] === 0 || input < 0.10) {
       break;
     }
    }
    while (input >= 0.05 && input < 0.10 && cid[1][1] > 0 || cid[2][1] === 0 && input >= 0.05 && cid[1][1] > 0) {
      cid[1][1] -= 0.05;
      input -= 0.05;
      copy.NICKEL += 0.05;
     if (cid[1][1] === 0 || input < 0.05) {
       break;
     } 
    }
    while (input > 0 && input < 0.05 && cid[0][1] > 0 || cid[1][1] === 0 && input > 0 && cid[0][1] > 0) {
      cid[0][1] -= 0.01;
      input -= 0.01;
      copy.PENNY += 0.01;
     if (cid[0][1] === 0 || input === 0) {
       break;
     }
    }
   if (input === 0) {
     break;
   }
  }
  if (cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1] > copy["ONE HUNDRED"] + copy.TWENTY + copy.TEN + copy.FIVE + copy.ONE + copy.QUARTER + copy.DIME + copy.NICKEL + copy.PENNY) {
    changeDue.textContent = 'Status: OPEN ';
    keys.sort((a, b) => copy[b] - copy[a]);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${copy[key]} `;
      }
   });
  } else if (cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1] === copy["ONE HUNDRED"] + copy.TWENTY + copy.TEN + copy.FIVE + copy.ONE + copy.QUARTER + copy.DIME + copy.NICKEL + copy.PENNY) {
    changeDue.textContent = 'Status: CLOSED ';
    keys.sort((a, b) => copy[b] - copy[a]);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
      changeDue.textContent += `${key}: $${copy[key]} `;
      }
    });
  }
  
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1]}<br>Nickels: ${cid[1][1]}<br>Dimes: ${cid[2][1]}<br>Quarters: ${cid[3][1]}<br>Ones: ${cid[4][1]}<br>Fives: ${cid[5][1]}<br>Tens: ${cid[6][1]}<br>Twenties: ${cid[7][1]}<br>Hundreds: ${cid[8][1]}</p>`;
  reset();
 }

btn.addEventListener('click', function () {
  conversion(inpt.value);
});



Should it reset the drawer contents after each transaction? Wouldn’t that revert any changes that were made during the transaction?

The last test is being caught in here:

if (input > cid[8][1] + cid[7][1] + cid[6][1] + cid[5][1] + cid[4][1] + cid[3][1] + cid[2][1] + cid[1][1] + cid[0][1]) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  }

Hi Sanity, I created a new post since I restarted from scratch. Still having problems.

Tell us what’s happening: Redid this project, not finished yet…but when testing it out with the values for status:open it works just fine but the tests are not accepting it. Neither is the input < price test which alerts that the customer does not have enough money.

Your code so far

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link href="styles.css" rel="stylesheet"> 
    <title>Register</title>
  </head>
  <body>
    <div id="parentcontainer">
      <h1>Cash Register</h1>
      <div id="change-due"></div>
      <div id="firstchild"><label for="cash">Enter Cash From Customer:</label> <input id="cash" type="number" required></input>
      <button id="purchase-btn">Purchase</button></div>
      <div id="childcontainer">
       
      </div>
    </div>
  <script src="script.js"></script>
  </body>
</html>


#change-due {
  width: 300px;
  height: 100px;
}

const changeDue = document.getElementById('change-due');
const childc = document.getElementById('childcontainer');
const btn = document.getElementById('purchase-btn');
const inpt = document.getElementById('cash');

const getTotalSum = (accumulator, currentValue) => accumulator + currentValue[1];

let cid = [
  ["PENNY", 101],
  ["NICKEL", 205],
  ["DIME", 310],
  ["QUARTER", 425],
  ["ONE", 9000],
  ["FIVE", 5500],
  ["TEN", 2000],
  ["TWENTY", 6000],
  ["ONE HUNDRED", 10000]
];

let copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
};
let price = 1950; 
function reset() {

  cid = [
  ["PENNY", 101],
  ["NICKEL", 205],
  ["DIME", 310],
  ["QUARTER", 425],
  ["ONE", 9000],
  ["FIVE", 5500],
  ["TEN", 2000],
  ["TWENTY", 6000],
  ["ONE HUNDRED", 10000]
];

  copy = {
    "PENNY": 0,
    "NICKEL": 0,
    "DIME": 0,
    "QUARTER": 0,
    "ONE": 0,
    "FIVE": 0,
    "TEN": 0,
    "TWENTY": 0,
    "ONE HUNDRED": 0
  };


  inpt.value = '';

}

window.addEventListener("load", (event) => {
  childc.insertAdjacentHTML('beforeend', `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`);
});

const convertToFloat = (amount) => parseFloat((amount / 100).toFixed(2));

const conversion = (input) => {
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`;
  let totalSum = cid.reduce(getTotalSum, 0);

  let change = input * 100 - price; 
  if (input < price / 100) {
    alert('Customer does not have enough money to purchase the item');
    return;
  } else if (change === 0) {
    changeDue.textContent = "No change due - customer paid with exact cash";
    return;
  } else if (totalSum < change) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  } else if (totalSum > change) {
    while (change > 0) {
      if (change >= 100 && cid[8][1] >= 10000) {
        change -= 10000;
        copy['ONE HUNDRED'] += 10000;
        cid[8][1] -= 10000;
      } else if (change >= 2000 && cid[7][1] >= 2000) {
        change -= 2000;
        copy.TWENTY += 2000;
        cid[7][1] -= 2000;
      } else if (change >= 1000 && cid[6][1] >= 1000) {
        change -= 1000;
        copy.TEN += 1000;
        cid[6][1] -= 1000;
      } else if (change >= 500 && cid[5][1] >= 500) {
        change -= 500;
        copy.FIVE += 500;
        cid[5][1] -= 500;
      } else if (change >= 100 && cid[4][1] >= 100) {
        change -= 100;
        copy.ONE += 100;
        cid[4][1] -= 100;
      } else if (change >= 25 && cid[3][1] >= 25) {
        change -= 25;
        copy.QUARTER += 25;
        cid[3][1] -= 25;
      } else if (change >= 10 && cid[2][1] >= 10) {
        change -= 10;
        copy.DIME += 10;
        cid[2][1] -= 10;
      } else if (change >= 5 && cid[1][1] >= 5) {
        change -= 5;
        copy.NICKEL += 5;
        cid[1][1] -= 5;
      } else if (change >= 1 && cid[0][1] >= 1) {
        change -= 1;
        copy.PENNY += 1;
        cid[0][1] -= 1;
      } else {
        break;
      }
    }

    changeDue.textContent = 'Status: OPEN ';
    let keys = Object.keys(copy);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${convertToFloat(copy[key])} `;
      }
    });
  }
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`;
  reset();
};

btn.addEventListener('click', function () {
  conversion(inpt.value);
});

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36

Challenge Information:

Build a Cash Register Project - Build a Cash Register

I think the current issue comes from expecting different unit for initial values. Tests are using specific values for cash, cid and price. Their unit is dollar, for example

When price is 3.26 , the value in the #cash element is 100 , cid is [["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]] ,

These are the values that will be set and tested. This means when code is expecting different units it might cause incorrect results.

This doesn’t mean internally function cannot use different units, but in that case the unit conversion need to explicitly happen in the process - test will not change units to conform to units used by your code.

Yeah because when I physically change every number to test every problem it works just fine. Here is the completed code:

const changeDue = document.getElementById('change-due');
const childc = document.getElementById('childcontainer');
const btn = document.getElementById('purchase-btn');
const inpt = document.getElementById('cash');

const getTotalSum = (accumulator, currentValue) => accumulator + currentValue[1];

let cid = [
  ["PENNY", 50],
  ["NICKEL", 0],
  ["DIME", 0],
  ["QUARTER", 0],
  ["ONE", 0],
  ["FIVE", 0],
  ["TEN", 0],
  ["TWENTY", 0],
  ["ONE HUNDRED", 0]
];

let copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
};
let price = 1950; 
function reset() {

  cid = [
  ["PENNY", 50],
  ["NICKEL", 0],
  ["DIME", 0],
  ["QUARTER", 0],
  ["ONE", 0],
  ["FIVE", 0],
  ["TEN", 0],
  ["TWENTY", 0],
  ["ONE HUNDRED", 0]
];

  copy = {
    "PENNY": 0,
    "NICKEL": 0,
    "DIME": 0,
    "QUARTER": 0,
    "ONE": 0,
    "FIVE": 0,
    "TEN": 0,
    "TWENTY": 0,
    "ONE HUNDRED": 0
  };


  inpt.value = '';

}

window.addEventListener("load", (event) => {
  childc.insertAdjacentHTML('beforeend', `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`);
});

const convertToFloat = (amount) => parseFloat((amount / 100).toFixed(2));

const conversion = (input) => {
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`;
  let totalSum = cid.reduce(getTotalSum, 0);
  console.log(totalSum);
  let change = input * 100 - price;
  console.log(change);
  if (input < price / 100) {
    alert('Customer does not have enough money to purchase the item');
    return;
  } else if (change === 0) {
    changeDue.textContent = "No change due - customer paid with exact cash";
    return;
  } else if (totalSum < change) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  } else if (totalSum > change) {
    while (change > 0) {
      console.log('Change:', change);
      console.log('ONE HUNDRED:', cid[8][1]);
      if (change >= 100 && cid[8][1] >= 10000) {
        change -= 10000;
        copy['ONE HUNDRED'] += 10000;
        cid[8][1] -= 10000;
        console.log('Distributed 100:', copy['ONE HUNDRED']);
      } else if (change >= 2000 && cid[7][1] >= 2000) {
        change -= 2000;
        copy.TWENTY += 2000;
        cid[7][1] -= 2000;
      } else if (change >= 1000 && cid[6][1] >= 1000) {
        change -= 1000;
        copy.TEN += 1000;
        cid[6][1] -= 1000;
      } else if (change >= 500 && cid[5][1] >= 500) {
        change -= 500;
        copy.FIVE += 500;
        cid[5][1] -= 500;
      } else if (change >= 100 && cid[4][1] >= 100) {
        change -= 100;
        copy.ONE += 100;
        cid[4][1] -= 100;
      } else if (change >= 25 && cid[3][1] >= 25) {
        change -= 25;
        copy.QUARTER += 25;
        cid[3][1] -= 25;
      } else if (change >= 10 && cid[2][1] >= 10) {
        change -= 10;
        copy.DIME += 10;
        cid[2][1] -= 10;
      } else if (change >= 5 && cid[1][1] >= 5) {
        change -= 5;
        copy.NICKEL += 5;
        cid[1][1] -= 5;
      } else if (change >= 1 && cid[0][1] >= 1) {
        change -= 1;
        copy.PENNY += 1;
        cid[0][1] -= 1;
      } else {
        break;
      }
    }
    console.log('Final change:', change);
    console.log('Copy:', copy);
    console.log('CID:', cid);

    changeDue.textContent = 'Status: OPEN ';
    let keys = Object.keys(copy);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${convertToFloat(copy[key])} `;
      }
    });
  } else if (totalSum === change) {
       while (change > 0) {
      if (change >= 100 && cid[8][1] >= 10000) {
        change -= 10000;
        copy['ONE HUNDRED'] += 10000;
        cid[8][1] -= 10000;
      } else if (change >= 2000 && cid[7][1] >= 2000) {
        change -= 2000;
        copy.TWENTY += 2000;
        cid[7][1] -= 2000;
      } else if (change >= 1000 && cid[6][1] >= 1000) {
        change -= 1000;
        copy.TEN += 1000;
        cid[6][1] -= 1000;
      } else if (change >= 500 && cid[5][1] >= 500) {
        change -= 500;
        copy.FIVE += 500;
        cid[5][1] -= 500;
      } else if (change >= 100 && cid[4][1] >= 100) {
        change -= 100;
        copy.ONE += 100;
        cid[4][1] -= 100;
      } else if (change >= 25 && cid[3][1] >= 25) {
        change -= 25;
        copy.QUARTER += 25;
        cid[3][1] -= 25;
      } else if (change >= 10 && cid[2][1] >= 10) {
        change -= 10;
        copy.DIME += 10;
        cid[2][1] -= 10;
      } else if (change >= 5 && cid[1][1] >= 5) {
        change -= 5;
        copy.NICKEL += 5;
        cid[1][1] -= 5;
      } else if (change >= 1 && cid[0][1] >= 1) {
        change -= 1;
        copy.PENNY += 1;
        cid[0][1] -= 1;
      } else {
        break;
      }
    }

    changeDue.textContent = 'Status: CLOSED ';
    let keys = Object.keys(copy);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${convertToFloat(copy[key])} `;
      }
    });
    
  }
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${cid[0][1] / 100}<br>Nickels: ${cid[1][1] / 100}<br>Dimes: ${cid[2][1] / 100}<br>Quarters: ${cid[3][1] / 100}<br>Ones: ${cid[4][1] / 100}<br>Fives: ${cid[5][1] / 100}<br>Tens: ${cid[6][1] / 100}<br>Twenties: ${cid[7][1] / 100}<br>Hundreds: ${cid[8][1] / 100}</p>`;
  reset();
};

btn.addEventListener('click', function () {
  conversion(inpt.value);
});

What do you propose I do?

Change and test code with the exact values from the tests. #cash, cid and price cannot have custom units.

Hi Sanity, look at the code below. I add what you recommended but it is still coming back as wrong. Everything checks out on my part, i am able to put in the values they are looking for in CID so instead of 50 as shown in my previous code I am able to put 0.50 and the code is functional.

const changeDue = document.getElementById('change-due');
const childc = document.getElementById('childcontainer');
const btn = document.getElementById('purchase-btn');
const inpt = document.getElementById('cash');

const getTotalSum = (accumulator, currentValue) => accumulator + currentValue[1];

let cid = [
  ["PENNY", 0.5],
  ["NICKEL", 0],
  ["DIME", 0],
  ["QUARTER", 0],
  ["ONE", 0],
  ["FIVE", 0],
  ["TEN", 0],
  ["TWENTY", 0],
  ["ONE HUNDRED", 0]
];

let ccid = cid.map(item => [item[0], item[1] * 100]);

console.log(ccid);

let copy = {
  "PENNY": 0,
  "NICKEL": 0,
  "DIME": 0,
  "QUARTER": 0,
  "ONE": 0,
  "FIVE": 0,
  "TEN": 0,
  "TWENTY": 0,
  "ONE HUNDRED": 0
};
let price = 19.50
function reset() {

  ccid = cid.map(item => [item[0], item[1] * 100]);

  copy = {
    "PENNY": 0,
    "NICKEL": 0,
    "DIME": 0,
    "QUARTER": 0,
    "ONE": 0,
    "FIVE": 0,
    "TEN": 0,
    "TWENTY": 0,
    "ONE HUNDRED": 0
  };


  inpt.value = '';

}

window.addEventListener("load", (event) => {
  childc.insertAdjacentHTML('beforeend', `<p id="paraEl">Change in drawer:<br>Pennies: ${ccid[0][1] / 100}<br>Nickels: ${ccid[1][1] / 100}<br>Dimes: ${ccid[2][1] / 100}<br>Quarters: ${ccid[3][1] / 100}<br>Ones: ${ccid[4][1] / 100}<br>Fives: ${ccid[5][1] / 100}<br>Tens: ${ccid[6][1] / 100}<br>Twenties: ${ccid[7][1] / 100}<br>Hundreds: ${ccid[8][1] / 100}</p>`);
});

const convertToFloat = (amount) => parseFloat((amount / 100).toFixed(2));

const conversion = (input) => {
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${ccid[0][1] / 100}<br>Nickels: ${ccid[1][1] / 100}<br>Dimes: ${ccid[2][1] / 100}<br>Quarters: ${ccid[3][1] / 100}<br>Ones: ${ccid[4][1] / 100}<br>Fives: ${ccid[5][1] / 100}<br>Tens: ${ccid[6][1] / 100}<br>Twenties: ${ccid[7][1] / 100}<br>Hundreds: ${ccid[8][1] / 100}</p>`;
  let totalSum = ccid.reduce(getTotalSum, 0);
  console.log(totalSum);
  let change = input * 100 - price * 100;
  console.log(change);
  if (input < price) {
    alert('Customer does not have enough money to purchase the item');
    return;
  } else if (change === 0) {
    changeDue.textContent = "No change due - customer paid with exact cash";
    return;
  } else if (totalSum < change) {
    changeDue.textContent = "Status: INSUFFICIENT_FUNDS";
    return;
  } else if (totalSum > change) {
    while (change > 0) {
      console.log('Change:', change);
      console.log('ONE HUNDRED:', ccid[8][1]);
      if (change >= 100 && ccid[8][1] >= 10000) {
        change -= 10000;
        copy['ONE HUNDRED'] += 10000;
        ccid[8][1] -= 10000;
        console.log('Distributed 100:', copy['ONE HUNDRED']);
      } else if (change >= 2000 && ccid[7][1] >= 2000) {
        change -= 2000;
        copy.TWENTY += 2000;
        ccid[7][1] -= 2000;
      } else if (change >= 1000 && ccid[6][1] >= 1000) {
        change -= 1000;
        copy.TEN += 1000;
        ccid[6][1] -= 1000;
      } else if (change >= 500 && ccid[5][1] >= 500) {
        change -= 500;
        copy.FIVE += 500;
        ccid[5][1] -= 500;
      } else if (change >= 100 && ccid[4][1] >= 100) {
        change -= 100;
        copy.ONE += 100;
        ccid[4][1] -= 100;
      } else if (change >= 25 && ccid[3][1] >= 25) {
        change -= 25;
        copy.QUARTER += 25;
        ccid[3][1] -= 25;
      } else if (change >= 10 && ccid[2][1] >= 10) {
        change -= 10;
        copy.DIME += 10;
        ccid[2][1] -= 10;
      } else if (change >= 5 && ccid[1][1] >= 5) {
        change -= 5;
        copy.NICKEL += 5;
        ccid[1][1] -= 5;
      } else if (change >= 1 && ccid[0][1] >= 1) {
        change -= 1;
        copy.PENNY += 1;
        ccid[0][1] -= 1;
      } else {
        break;
      }
    }
    console.log('Final change:', change);
    console.log('Copy:', copy);
    console.log('CID:', ccid);

    changeDue.textContent = 'Status: OPEN ';
    let keys = Object.keys(copy);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${convertToFloat(copy[key])} `;
      }
    });
  } else if (totalSum === change) {
       while (change > 0) {
      if (change >= 100 && ccid[8][1] >= 10000) {
        change -= 10000;
        copy['ONE HUNDRED'] += 10000;
        ccid[8][1] -= 10000;
      } else if (change >= 2000 && ccid[7][1] >= 2000) {
        change -= 2000;
        copy.TWENTY += 2000;
        ccid[7][1] -= 2000;
      } else if (change >= 1000 && ccid[6][1] >= 1000) {
        change -= 1000;
        copy.TEN += 1000;
        ccid[6][1] -= 1000;
      } else if (change >= 500 && ccid[5][1] >= 500) {
        change -= 500;
        copy.FIVE += 500;
        ccid[5][1] -= 500;
      } else if (change >= 100 && ccid[4][1] >= 100) {
        change -= 100;
        copy.ONE += 100;
        ccid[4][1] -= 100;
      } else if (change >= 25 && ccid[3][1] >= 25) {
        change -= 25;
        copy.QUARTER += 25;
        ccid[3][1] -= 25;
      } else if (change >= 10 && ccid[2][1] >= 10) {
        change -= 10;
        copy.DIME += 10;
        ccid[2][1] -= 10;
      } else if (change >= 5 && ccid[1][1] >= 5) {
        change -= 5;
        copy.NICKEL += 5;
        ccid[1][1] -= 5;
      } else if (change >= 1 && ccid[0][1] >= 1) {
        change -= 1;
        copy.PENNY += 1;
        ccid[0][1] -= 1;
      } else {
        break;
      }
    }

    changeDue.textContent = 'Status: CLOSED ';
    let keys = Object.keys(copy);
    keys.forEach((key, index) => {
      if (copy[key] > 0) {
        changeDue.textContent += `${key}: $${convertToFloat(copy[key])} `;
      }
    });
    
  }
  childc.innerHTML = `<p id="paraEl">Change in drawer:<br>Pennies: ${ccid[0][1] / 100}<br>Nickels: ${ccid[1][1] / 100}<br>Dimes: ${ccid[2][1] / 100}<br>Quarters: ${ccid[3][1] / 100}<br>Ones: ${ccid[4][1] / 100}<br>Fives: ${ccid[5][1] / 100}<br>Tens: ${ccid[6][1] / 100}<br>Twenties: ${ccid[7][1] / 100}<br>Hundreds: ${ccid[8][1] / 100}</p>`;
  reset();
};

btn.addEventListener('click', function () {
  conversion(inpt.value);
});

Almost there. Notice that conversion to the units used by function needs to happen every time function is used - if contents of change drawer are changed by test units again might not be correct.