JS Calculator Project - Can't get the past the last 3 tests

Here’s my codepen JS Calculator (codepen.io)

I can’t get these past these last 3 requirements:

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”

^ But it does?

11. When the decimal element is clicked, a “.” should append to the currently displayed value; two “.” in one number should not be accepted

^ Not sure how to get it to display 5.55 when you throw 5.5.5 in there.

13. If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign.

When I actually use the calculator do manually do some of the, the required output is as is needed to past these tests. But sometimes it doesn’t?? I’m kind of at a loss to figure out how to get past these haha. Any hints?

Try the suggestions from the failing tests. If I evaluate 5 - 9 + 5 with your calculator I get -9. I shouldn’t be able to enter 5.5.5 but I can. You’ll have to check for multiple decimal points as input is entered. Entering 5 + - 8 doesn’t work because all I can enter is 5 + 8; you have to accept 5 + - 8 as valid input.

You should log the various steps in updateCalc and calculateExpression to determine what the code is actually doing.

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