@shimphillip that’s incorrect. Order of operations for the sequence you mentioned 5 - 2 / 2 = would be 5 - (2 / 2) = so 4 is the correct answer.
Math order of operations is PEMDAS
@orvalho I’m not sure why the test fails. I tried and it seems your calculator does fulfill the story. Granted, I haven’t done this one yet but I’d expect the results to pass too.
You wrote 5 - 2 / 2 =
the test says 5 - 2 = / 2 = and that indeed should (and does) equal 1.5
And odd, but when I put that in his calc it does correctly output 1.5
@orvalho didn’t mean to hijack your thread. I believe you can skip this test because your answer is correct. It may be that the text of the test was written to be 5 - 2 = / 2 but the actual test is doing 5 - 2 / 2 = which as we know are two different equations.
@shimphillip, @Roma thank you both for your insight
The important thing is that my calculator does fulfill user story (though FCC test doesn’t acknowledge it).Thanks for reassurance
I know enough JS to be dangerous. I read something earlier that FCC was written for humans by humans so there will be errors. I’ll keep it in the back of my mind to go to GitHub and look at FCC’s test for this and write an issue if one is warranted, which it seems it is.
The test runs very fast, and it failed because there was a 10 ms delay before you updated your input state again.
Of course, when you do it manually, it worked as expected because we can’t input the whole error causing expression in under 10 ms.
Have a look on this version as well, I just increased the time to 10 seconds so you can see what’s happening and why you are getting 4 as in output in tests.
Thank you everyone for your help! When I posted my question I thought it was a long shot and didn’t expect that anyone would take time to go through my code as I couldn’t pinpoint which part of my code was causing test to fail. @husseyexplores thanks a lot for solving the issue and for great explanation too.