Build a Cash Register Project - Build a Cash Register

Tell us what’s happening:

I am not able to pass the last check of the Cash Register Project, although my code generate the exact same output required.

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.

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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Build a Cash Register Project - Build a Cash Register

it’s bugged, you can follow the progression on fixing the issue here: New Cash Register Project test bug · Issue #52688 · freeCodeCamp/freeCodeCamp · GitHub

1 Like

It s still bugged!!!
f

yes, it’s difficult it’s going to be resolved in 2 hours

1 Like

Awesome!
you can try use my code to fix it. let price = 19.5;
let cid = [
[“PENNY”, 0.5],
[“NICKEL”, 0],
[“DIME”, 0],
[“QUARTER”, 0],
[“ONE”, 0],
[“FIVE”, 0],
[“TEN”, 0],
[“TWENTY”, 0],
[“ONE HUNDRED”, 0],
];
const notes = [0.01, 0.05, 0.1, 0.25, 1, 5, 10, 20, 100];

const cashInput = document.getElementById(“cash”);
const changeDue = document.getElementById(“change-due”);
const purchaseBtn = document.getElementById(“purchase-btn”);

const makePurchase = () => {
let cash = Number(cashInput.value);

if (!cash) {
changeDue.textContent = “”;
return;
}

switch (true) {
case cash < price:
alert(“Customer does not have enough money to purchase the item”);
break;
case cash === price:
changeDue.textContent = “No change due - customer paid with exact cash”;
break;
default:
let change = cash * 100 - price * 100;
let depletedNumberOfNotes = 0;
let changeDueTextContent = “”;

  for (let i = notes.length - 1; i >= 0; i--) {
    if (cid[i][1] === 0) depletedNumberOfNotes++;

    const note = notes[i] * 100;
    const numberOfNotesToReturn = Math.trunc(change / note);
    if (!numberOfNotesToReturn) continue;

    const cashAmountOfNotesInCashDrawer = cid[i][1] * 100;
    if (!cashAmountOfNotesInCashDrawer) continue;

    const cashToReturnFromNote = Math.min(
      numberOfNotesToReturn * note,
      cashAmountOfNotesInCashDrawer
    );

    if (cashToReturnFromNote > 0) {
      const cashToSubstract = cashToReturnFromNote / 100;
      cid[i][1] -= cashToSubstract;
      if (cid[i][1] === 0) depletedNumberOfNotes++;
      changeDueTextContent += `${cid[i][0]}: $${cashToSubstract} `;
      change -= cashToReturnFromNote; // change % note;
    }
  }

  if (change) {
    changeDueTextContent = "Status: INSUFFICIENT_FUNDS";
  } else if (depletedNumberOfNotes === cid.length) {
    changeDueTextContent = "Status: CLOSED " + changeDueTextContent;
    // Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5
  } else {
    changeDueTextContent = "Status: OPEN " + changeDueTextContent;
  }

  changeDue.textContent = changeDueTextContent;

}
};

purchaseBtn.addEventListener(“click”, makePurchase);

Hello,
Is there any update regarding this bug?

the fix has been merged, the next deployment of the site will bring the fix to the live website

hi sir, can I ask when will the next deployment of the site bring the fix? I am very would like to get my certificate.

I also facing with the same last error, even though my
actual and expected output is the same and test should pass but it fails with error
element should be Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5`

expected output 'Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5' 
actual output 'Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5'

I have the same problem and am assuming its the bug that was reported earlier that hasn’t been fixed yet. Just in case - there is a backtick after 0.5 in your error question - could that possibly be it?