Javascript calculator - disable button for multiple decimal is not accepted

Hi,

I am trying to build the calculator, but I have issues with user stories 11 (and 12).

If I allow multiple decimal points (which is of course not acceptable), I can pass user story 12 (operations on decimal numbers).

If I disable the button decimal after the first press:

if(event.target.innerHTML === '.')
document.getElementById("decimal").disabled = true;

and of course I re-eanble it when I press an operation or the equal sign, I still am not able to pass user story 11, and in addition I can pass user story 12 anymore!

But the calculator does its job: I can’t add more than one decimal per number, and I can perform calculations on decimal numbers… :frowning:

Could anyone please help?

Here is my pen for reference:
https://codepen.io/simone-saimon-rossi/pen/LYbQWyr

Thank you

Kind regards

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36.

Challenge: Build a JavaScript Calculator

Link to the challenge:

Hey Simone,

great work so far! :clap:

You can have a look at the tests and how they work:

Because debugging is a very valuable skill to learn, try to understand the tests on your own and let us know if you need some help.

This is speculation, but I’m thinking he test may not like that you are disabling the button because what it ends up seeing is a non function decimal button

Solved!
I didn’t re-enable the button “decimal” when I press “Clear”… This solved both user stories! :open_mouth:
Thank you both!

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