FCC: Javascript Calculator, User Story #13

Hi everyone, i hope that you are well.
So my problem is:
the project is a javascript calculator from front end certificate.

I Cannot understand why the FCC test suite is stuck in the user story 13

User Story #13: If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign). For example, if 5 + * 7 = is entered, the result should be 35 (i.e. 5 * 7); if 5 * - 5 = is entered, the result should be -25 (i.e. 5 * (-5)).

We don’t really need it, but this is the test that is failing:

      it(`If 2 or more operators are entered consecutively, the
      operation performed should be the last operator entered (excluding
      the negative (-) sign.`, async function () {
        clickButtonsByIdWithDelay([_5, _x, _min, _5, _eq], CLICK_DELAY);
        await timeout(DELAY);
        assert.strictEqual(
          getInputValue(document.getElementById('display')),
          '-25',
          'The sequence "5 * - 5" = should produce an output of "-25" '
        );
        clearDisplay();
        clickButtonsByIdWithDelay([_5, _x, _min, _plus, _5, _eq], CLICK_DELAY);
        await timeout(DELAY);
        assert.strictEqual(
          getInputValue(document.getElementById('display')),
          '10',
          'The sequence "5 * - + 5" = should produce an output of "10" '
        );
        clearDisplay();
        clickButtonsByIdWithDelay([_5, _plus, _plus, _5, _eq], CLICK_DELAY);
        await timeout(DELAY);
        assert.strictEqual(
          getInputValue(document.getElementById('display')),
          '10',
          'The sequence "5 + + 5" = should produce an output of "10" '
        );
      });

The error message tells us what we need to know, it is saying:

The sequence “5 * - + 5” = should produce an output of “10” : expected ‘-25’ to equal ‘10’

So, it is seeing -25 in there but is expecting 10.

When I enter that sequence of keys, that is what I see, too.

Does that makes sense?

Be sure to read the failing test messages - they are trying to give you clues.

2 Likes

Thanks, where i can find the failing test messages ?

If you hit the red “13/16 Passed”, a readout of the outcomes of the tests will be shown.

Screen Shot 2022-09-07 at 08.20.13

1 Like

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