Fail test of JavaScript calculator

Hi guys,

I am building this JavaScript calculator with ReactJS.
But i failed to pass case#9, #12, #13, #14.
Because when i manually verify them, i get the correct one. Not sure which goes wrong…

https://codepen.io/WongYC-66/full/WNaJMzP

Below are the fail case:

9. In any order, I should be able to add, subtract, multiply and divide a chain of numbers of any length, and when I hit “=”, the correct result should be shown in the element with the id of “display”

The expression 5 - 9 + 5 should produce a result of 1

12. I should be able to perform any operation (+, -, *, /) on numbers containing decimal points.

The expression “5 * 5.5” should produce an output of “27.5” : expected ‘302.5’ to equal ‘27.5’

13. 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 ‘-1275’ to equal ‘10’

14. Pressing an operator immediately following “=” should start a new calculation that operates on the result of the previous evaluation

The sequence “5 + 5 = + 3 =” should produce an output of “13” : expected ‘9.55’ to equal ‘13’

Thanks.

Looks to be an issue with React 18 and the tests. Switching to the old render method makes all but one test pass.

ReactDOM.render(<App />, document.querySelector("#root"))

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

Which is what I get as well when entering it manually.

1 Like

You are a life saver.

Now i finally can continue my debugging. Thank you Mr Lasjorg.

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