Build a Cash Register Project - Cannot Pass Final User Story

Tell us what’s happening:

Hello there, my code for this project is passing all but the final user story, and I cannot figure out why. The function below is what turns an array of the types of currency being made into change into a string to set as the textContent of the #change-due element.

In my own testing it is spitting out the correct answer, but it is not accepted. I have added some console outputs to compare the string the test is asking for and the string that I am returning, and they are a perfect match. I have included the console output below.

Your code so far

function composeChangeDue(change) {
    let string = `Status: ${isOpen ? "OPEN" : "CLOSED"} `;
    if (change === undefined) {
        string = "Status: INSUFFICIENT_FUNDS";
        return string

    const entries = Object.keys(change);
    entries.forEach(entry => {
        const subString = `${entry}: $${fixPrecision(change[entry])} `;
        string += subString;


    return string.trim();

Console output:

// running tests
When price is 19.5, the value in the #cash element is 20, cid is [["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]], and the #purchase-btn element is clicked, the value in the #change-due element should be Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5.
// tests completed
// console output 
Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0

Challenge Information:

Build a Cash Register Project - Build a Cash Register

Adding the code for my calculate change function, I assume it may be relevant.

function calculateChange(amount) {
    const sortedDrawer = cid.slice(0).reverse();
    const drawerAmount = calculateTotalCid();
    let changeAmount = amount - price;
    let changeComp = {};

    // console.log(drawerAmount, changeAmount);

    //Check drawer
    if (drawerAmount < changeAmount) {
        return undefined
    if(drawerAmount === changeAmount) {
        isOpen = false;

    //Make change
    for (let tender in sortedDrawer) {
        const tenderName = sortedDrawer[tender][0]
        const tenderValue = tenderValues[tenderName];
        let tenderAmount = sortedDrawer[tender][1];
        const cidIndex = cid.indexOf(sortedDrawer[tender]);

        console.log(isOpen, tenderName, tenderValue, changeAmount);
        if (!isOpen && tenderValue <= changeAmount) {
            changeComp[tenderName] = 0;

        while (changeAmount >= tenderValue && tenderAmount >= tenderValue) {
            changeAmount -= tenderValue;
            tenderAmount -= tenderValue;
            tenderAmount = fixPrecision(tenderAmount);
            changeComp[tenderName] ? changeComp[tenderName] += tenderValue : changeComp[tenderName] = tenderValue;
            changeAmount = fixPrecision(changeAmount);
    const returnCondition = changeAmount === 0;
    return returnCondition ? changeComp : undefined

After a lot of investigating the source code of the example project, not even it would pass the final user story. The user story asks for a return of:

Status: CLOSED QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5

However the example project (which I edited some values with a script override to replicate the final user story) returns the following:

Status: OPEN QUARTER: $0 DIME: $0 NICKEL: $0 PENNY: $0.5

So I changed my objectively correct code to give the same wrong output of the example project and I was able to pass the challenge. I will open an issue on GitHub for this discrepancy.

It is a known bug that has been fixed but has not been pushed to production yet.

Please do not submit your project with the wrong code just to pass the last test. Wait for the fix to land and then resubmit using the correct code.

Oops! Too late then, I submitted hours ago haha

In an academic sense I know I shouldn’t submit “wrong” code to pass a test, but I don’t see any real issue of submitting something wrong when I know it is wrong, and originally had something that was right from following the instructions I was given.

It was actually a great learning experience figuring out what I needed to do to “fool the machine”. I’m pretty sure I wouldn’t have been able to figure this out a week or two ago, so this is still a solid win for fcc in my book!

You can resubmit it again with the correct code when the challenge has been fixed,

The issue with submitting the wrong code is that if anyone checks the code or runs it again after the fix, it will fail.

It is up to you but I would suggest you resubmit it again with the correct code. I know it’s annoying but better safe than sorry.

I will definitely try to loop back on this. Is there any good way to know when the curriculum code is updated? From a convo on GitHub it seems like it doesn’t necessarily happen on a regular interval like nightly, etc.

There is not a great way to check other than to look for the PR on the prod-current branch.

I doubt it will cause you any issue seeing as it is our fault that the test is bugged. But I would just wait a week and try again with the correct code.

1 Like

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