Not being able to create post

Hi everyone,
I am trying to create a post directly from the “Cash Register Project” to get help, but for some reason it does not work. Once I press “submit” the post window dissapears and nothing happens. Does anyone knows what could be the reason? Thanks :slight_smile:

Did you do all the suggestions and requirments to submit. If you did all that refresh your browser or inspect the browser console for the error.

Hello!
which browser are you using?

1 Like

google chrome but I already tried with safari and the same happens :frowning:

Yes, it is weird. I checked both box, wrote the text describing the problem, but when i click submit, the window dissapear and nothing happens.
I checked the console and nothing happens when I click the “submit” button. However there are some errors displayed in the console that I am not sure what they mean. You can see in the picture :slight_smile:

You can clear this out by using the no sign at the top or Ctrl + L. Its a little hard to see where the error is because the console keeps logging one after the other. Good luck

1 Like

Thanks for the Ctrl + L shortcut it will be usefull :slight_smile: . But unfortunatelly the problem is related to something else :confused:

1 Like

The React related errors shouldn’t be there, the others are fine.

Can you scroll up so we can see all the error message related to react-dom


Did you try without any browser extensions?

I just tested it and it worked for me.

1 Like


Are you able to see in this screenshot? There are many errors, but I thought it could be maybe this TypeError to Symbol.
And yes I already tried to turn off all the extensions, tried on Saffari but so far nothing works. It is really weird.

That definitely looks like the issue.

My best guess is you are somehow blocking some of the needed JS files/scripts.

I would install the Canary version of Chrome and leave it fresh, do not install any extensions. Test with that. It is a good idea to have a clean browser for development anyway, so it is handy to have it.

Make sure you do not have any security software that is blocking resources.

Test it on a different system or network if you can.


If it works in the clean version of Chrome, make sure you clear your cache in your other browsers and do a hard refresh on the page Shift+F5

1 Like

Nice tip thanks, I just downloaded the Canary Chrome. But unfortunatelly I get the same exact error :confused: . It is funny because I’ve created posts before with this same computer, same network, same browser and then suddenly it does not work anymore. Thank you from trying to help :slight_smile:

Not sure, it works for me, both signed in and out.

Does it fail on all the challenges, or just this one?

Can you try signing out of the curriculum and testing it again being signed out?

If you go to the network tab in the browser dev tools and reload the page, is any client side code getting blocked? You can post an image.

Also, check the “Disable cache” at the top of the Network tab and leave the dev tools open, then reload the page.

2 Likes

So I just found out that it only fails on this specific challenge. In other challanges I was able to proceed to the next page and continue with the Post. Could it be a bug in this challenge?

Did it work for you in this specific challenge (The JavaScript Cash Register Project )?

And yes, I disabled cache and reload the page and all the client side code is running normal, nothing blocked.

I tested it with this challenge without any code, and it worked for me.

If you remove all your code, does it work?

Do you have a saved version, that is, if you load the page is it filled out with your previous code?

Can you please post your code so we can test with it?

1 Like

It still does not work with all the code deleted :confused: Really don’t get it. Bellow is my javascript code:
obs.: I tried removing the JQuery and Bootstrap to see if it was causing the problem but it still did not work :frowning:

const cash = document.getElementById("cash");  
const purchaseBtn = document.getElementById("purchase-btn");
const changeDueContainer = document.getElementById("change-due");
const cidContainer = document.getElementById("cid");
const codContainer = document.getElementById("cod");
const codHeader = document.getElementById("cod-header");
const cidStatusDom = document.getElementById("status");

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

const isCashEnough = () => {
    const cashFixed = cash.value; 
    const priceFixed = price;
    if (Number(cashFixed) === Number(priceFixed)) {
        alert("No change due - customer paid with exact cash");
        return true; 
    } else if (Number(cashFixed) > Number(priceFixed)) {
        return true;
    } else {
        alert("Customer does not have enough money to purchase the item");
        return false;
    }
};

const changeDue = (cash, price) => parseFloat((cash.value - price).toFixed(2));

const convertMap = [
    {string: "ONE HUNDRED", value: 100},
    {string: "TWENTY", value: 20},
    {string: "TEN", value: 10},
    {string: "FIVE", value: 5},
    {string: "ONE", value: 1}, 
    {string: "QUARTER", value: 0.25},
    {string: "DIME", value: 0.1},
    {string: "NICKEL", value: 0.05},
    {string: "PENNY", value: 0.01}
];

const breakChange = () => { 
    let change = changeDue(cash, price);
    let subtrahends = [];
    const tempCid = cid.map(([denomination, amount]) => [denomination, amount]); // Copy of cid
    
    convertMap.forEach(money => {
        let denomAmount = tempCid.find(([denom]) => denom === money.string)[1];
        
        
        while (change >= money.value && denomAmount > 0) {
            subtrahends.push({key: money.string, value: money.value});
            change = parseFloat((change -= money.value).toFixed(2));
            denomAmount = parseFloat((denomAmount -= money.value).toFixed(2));
        }
    }); 
    
    if (change > 0) {
        alert("Status: INSUFFICIENT_FUNDS");
        return []; // Return an empty array to indicate failure
    }
    
    return subtrahends;   
};

const updateCid = () => {
    const subtrahends = breakChange();
    let cidStatus = "Status: OPEN";

    if (subtrahends.length === 0) {
        cidStatus = "Status: INSUFFICIENT_FUNDS";
        cidStatusDom.innerText = cidStatus;
        return cid; // Stop updating cid
    }

    subtrahends.forEach(subtrahend => {
        const moneyDrawer = cid.find(money => money[0] === subtrahend.key);

        if (moneyDrawer && moneyDrawer[1] >= subtrahend.value) {
            moneyDrawer[1] = parseFloat((moneyDrawer[1] - subtrahend.value).toFixed(2));
            cidStatus = "Status: OPEN";
        }
    });
    
    cidStatusDom.innerText = cidStatus;
    return cid;
};

const displayCid = () => {
    const updatedCid = updateCid();
    cidContainer.innerHTML = '';  
    updatedCid.forEach(array => {      
        cidContainer.innerHTML += `${array[0]} : ${array[1].toFixed(2)}<br>`;         
    });
    };

displayCid();

purchaseBtn.addEventListener("click", () => {
    changeDueContainer.innerHTML = "";
    codContainer.innerHTML = "";
    cidContainer.innerHTML = "";

    if (isCashEnough()) {
        const change = changeDue(cash, price);
        const givenCash = parseFloat(cash.value).toFixed(2);
        const subtrahends = breakChange();
        const repeatedSubtrahends = {};

        subtrahends.map(subtrahend => {
            if (repeatedSubtrahends[subtrahend.key]) {
                repeatedSubtrahends[subtrahend.key] += subtrahend.value;
            } else {
                repeatedSubtrahends[subtrahend.key] = subtrahend.value;
            }
        });

        console.log(repeatedSubtrahends);

        changeDueContainer.innerHTML = `
        Cash: <span class="positive">$ ${givenCash}</span><br>
        Price: <span class="negative">$ ${price.toFixed(2)}</span><br>
        <span class="fw-bold">Change: <span class="positive">$ ${change}</span></span>
        `;
        codContainer.innerHTML = `
        <h4 class="text-center"><span class="negative">Cash-Out</span></h4>
        `;
        for (const [key, value] of Object.entries(repeatedSubtrahends)) {
            codContainer.innerHTML += `
            <p class="text-center fs-6">${key}<br><span class="negative">-${value.toFixed(2)}</span></p>`;
        }
        
        displayCid();
        cash.value = "";
        
        /*-------------------- jQuery styling------------------------------*/
        $(".positive").css("color", "green"); 
        $(".negative").css("color", "red");
        /*-------------------- jQuery styling------------------------------*/ 
    } else {
        displayCid();
        cash.value = "";
    }
});

to reproduce, your html is also needed

1 Like

Can you try submitting with no code, no HTML/CSS/JS. So that if you reload, it should come back empty. Now clear the browser cache and cookies, and try it again.

1 Like

I finally found out the problem! It was my network.
Today I am working from a hotel and I was able to create the post the first time without any problems. Thank you guys for the help! :slight_smile:
By the way, any idea what could be causing such error in my network?
@lasjorg @ilenia

Not really, especially not as it hasn’t happened before or doesn’t happen on other pages.

It could be some sort of content filtering on the router/network, but that seems a little unlikely. You could try bypassing your router or using a VPN to bypass any filtering done on the ISP side. You could also try a different DNS server.

1 Like

Yes exactly, it is a very weird error. I will give the VPN a try once I am back home. Thanks a lot for the help :slight_smile: