Fail to pass the test of FCC JavaScript Calculator

Hi, I need help here. I do not manage to pass the test because of this error:

When the decimal element is clicked, a “.” should append to the currently displayed value; two “.” in one number should not be accepted

I couldn’t solve the problem. Please help.

You sholdn’t be able to enter numbers like 1.3.4 (only one decimal per number, e.g. 1.4)

I know, but how to solve it?

You can test if the current value has already a decimal point and make the action void if that is the case (make no action occur)

Took me a while to find a bug :grinning:
It’s in Container -> inputBtn:

var operators = /[+-\/*]/g;

Go to, paste your regex and see what it matches.

1 Like

Thank you so much, I have solved the problem. :slight_smile:

You could’ve just fixed your regex:

var operators = /[+\-\/*]/g; // escape minus symbol
1 Like

Oh I see, thank you :slight_smile: