Front End Development Libraries Projects - Build a JavaScript Calculator

Tell us what’s happening:
Failing to pass the tests 9 to 15. The test #9 tells me that: The expression 3 + 5 * 6 - 2 / 4 should produce 32.5 or 11.5, and I expect other test are not executed, because it seems that my project follows most of the rules listed, I am just not sure about how many places behind decimal point my result displays.

So the problem is that the tests makes me think that my results do not match the expected outcome, however my test tells me otherwise:

This is not the first calculator project I have written, the previous project was a challenge from frontendmentor.io. The project was only vanilla JavaScript - link to it.

Since this time I am using a framework I decided to get fancy and make use of math.js API,

I know it was not recommended to use any not listed technologies, however this way I feel like I do display the step forward I have made, for myself and for potential employer.
So I would rather troubleshoot and keep the API then write code that would calculate the result for me, of course if someone would be willing to lend their knowledge to help me out.
The main current suspect is that the server has a delay to respond with the result.
I hope it is OK to share the link to current state of the project at codepen…
Link to codepen

Your browser information:

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

Challenge: Front End Development Libraries Projects - Build a JavaScript Calculator

Link to the challenge:

Perhaps you have already fixed the problem, because when I run your codepen, it passes test #9.

Not sure why but I am not allowed to edit the main post (I have edited it today). I would had liked to delete the link to codepen, however my edit is glowing orange and I can only view changes made to the post.

So this is an update. Just to pass the test I have decided to ditch the API. This project in the form I would like it to take will take place in my portfolio. Mean while since I could not delete the link to codepen I deleted the codepen itself.

Doing this only to not regret sharing it later since it is a project used to earn certification.

After writing a function instead of API to calculate the inputed string I am left with these two:

    1. If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign.
      The sequence "5 * - + 5" = should produce an output of "10" : expected '-25' to equal '10'
    1. Pressing an operator immediately following “=” should start a new calculation that operates on the result of the previous evaluation
      The sequence "5 - 2 = / 2 =" should produce an output of "1.5" : expected '2' to equal '1.5'

Just a quick update for people trying to access the codepen…

Do you have a link to the current version of your code?

Project complete

The project by now has passed all tests.

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