My function is being invoked without pressing the purchase button.
When I press the button afterward with a value, nothing happens.
Editing the code will make the alert pop up again on my browser.
How do I prevent this?
mackenziewhtn, I’m working on this project so that I can know how to help you with it.
I have done the following:
Create a CID object for every unique CID shared in the instructions of this challenge.
Concisely name keys in the CID object.
In calculateChange() after the “cashValue < price” if condition, write “cashValue === price” else if condition(yours could use space before and after === as a format improvement) with changeDue text updated to ‘No change due - customer paid with exact cash’(as this challenges instructions instruct) with textContent.
Remove the parentheses after calculateChange in the purchaseBtn click event listener, as written in lasjorg’s reply.
Two industry standard problem solving methods are an effective pair, namely rubber duck debugging(rubber duck not required, any reasonable object or a picture of our Lord Jesus could work too) and using a search engine(Brave Search, Google Search, Ecosia Search, etc).
Rubber duck debugging can be described as explaining a problem to an inanimate object(writing in a notebook could be effective rubber duck debugging) and this can help a problem solver protect their ideas, strengthen their problem solving ability, increase their confidence as a problem solver, save others’ attention, and problem solve.
Update: I think storing just the first CID written in the User Stories is sufficient to begin the CID.