Front End Development Libraries Projects - Build a JavaScript Calculator

I’m currently working on the Calculator app, I’m using React for this project.

Unfortunately I keep getting these errors for my code (I attached one screenshot)

Now while i keep getting these errors, when i check manually the code is working according to the tests and I don’t understand why i keep getting these

When I type 2 or more operators consecutively, the operation performed is the last operator entered (excluding the negative (-) sign), as asked. Same with the last error of 5 / 2 = / 2 = 1.5 which is exactly the result i get but I still get the error. :slightly_frowning_face:

These are the user stories i don’t pass according to the tests :

  1. User Story #14: 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 ‘276’ to equal ‘1.5’)
  2. 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) ).

This is the link for my project in CodePen https://codepen.io/rita-gr/pen/wvNXVMW

I would really appreciate any help :face_holding_back_tears:

Challenge Information:

Front End Development Libraries Projects - Build a JavaScript Calculator

Try 10 * / - + 5. Be sure to have the dev tools console open.

Yes, I am showing that your calculator is producing the correct answer for this test. Not sure what is going on here?

Thank you so much for pointing that out! I guess i was sitting on the code for too long without paying attention to two or MORE, so haven’t checked for more than two operators.
I just fixed my function and 16/16 tests passed!
Thanks a lot :face_holding_back_tears:

2 Likes

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