Decimal button not working on my calculator project


I cannot get the decimal button to work in my calculator.

I’ve tried to have a var that when switched to on stops the decimal button from working. Unfortunately when clicking the decimal button two decimals are appearing and the decimal is not being dissabled. I think something is wrong with my if else statement.

CODE pen is here:


I take it you’ve fixed this problem, as the decimal doesn’t behave the way you describe and seems fine.

Good work!

By the way, the behavior is not as I would expect after getting a result. I would expect to be able to begin a new calculation without pressing ‘clr’ first.

Also, I would expect ‘8’, followed by ‘=’ (for example) to display ‘8’ not ‘0’.

Minor points, and your calculator basically works, so you may prefer to move on rather than address these issues.