JS Calculator - Tests not passing

Hello!

So I wrote this js calculator app months ago (legacy).

Somehow it doesn’t pass some very simple tests on the FCC suite even if it has the actual requirements of the tests…

Do i have to restart / abandon this version?

here is the link:

Thanks in advance!

As far as the test for the id=“equals” and the id=“decimal”, the test seems to be a little picky. It is not expecting a newline character. You have written each of these buttons with following syntax:

<button class="operator" id="equals">
=
</button>

<button class="operator" id="decimal">
.
</button>

If you rewrite the above as the following, it will pass those two tests.

<button class="operator" id="equals">=</button>

<button class="operator" id="decimal">.</button>

To cutdown on the number of lines of your HTML, I would do the same for all of those buttons.

As far as test #8 (seen below), I think the fact that if the first number I type is 4, your display shows 04 instead of just for, that maybe the problem. Honestly, I am not sure why you keep the 0 in front.

As I input numbers, I should be able to see my input in the element with the id of “display”

You are failing test #11, because your calculator allows me to enter 2.2.5 as a number.

You are failing test#12, because your calculator will not calculate 10.5 - 5.5

I managed to get it to 14/16 by fixing html(like you noticed indeed) and input details (replacing the 0 base input by the single digit whilst it wasnt doing that).

However, it s still failing 12 and 13.
Working on it

Update : Oh i see it s because my logic for allowing one “.” per number is for the whole string.
Update: Okkk so i did it …took me about 90 mins! There was a very specific case that needed some adjustement in the = area.