Tell us what’s happening:
Describe your issue in detail here.
Hi, I am unable to pass these two run test questions:
##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”
If 2 or more operators are entered consecutively, the operation performed should be the last operator entered (excluding the negative (-) sign.
Well, this project introduces some more complex issues that you don’t seem to have addressed in your code. For one, it doesn’t seem you’ve implemented the " ." into your code, but maybe you just haven’t gotten there yet.
Regarding the problems you’ve mentioned, it doesn’t seem you’ve included the ability to enter a negative number. For instance, entering 5 * - 5 should have a result of -25… Five times negative 5. Instead you get 0 because the - overwrote the *.
Also, it doesn’t seem you have programmed a method for stringing multiple operations together… for instance, 5 * 5 - 2 should result in 23 (five times five minus 2) but instead you’re calculator only remembers the last two operators, resulting in 5-2=3.
Seems you’ve got some more problem solving to do. Hope that makes sense. If you have a specific question regarding how to do that let us know.
Hi kinome79 please help I manage to add ’ . ’ decimal key however the last 2 method for stringing multiple operations together… for instance, 5 * 5 - 2 should result in 23
formula v immediate 3+5*6-2/4 string, I am lost .
Any hint would be appreciated.
please see my linkJS calculator
Other than that, I don’t want to nay-say your design because maybe I don’t completely understand what’s going on, but it seems you’re relying on a very fixed equation layout… firstnum, operator, secondnum = result. The problem is that doesn’t leave room for someone typing a more complex operation.
For instance, when the calculator first comes up I typed . 5 = . The result was a blank screen. I then typed +2 and got a NaN error. It’s because I didn’t stay within your number, operator, number template.
As the point of the project is to design an app to solve this problem, I can’t really tell you how to design it. There are many ways, a complex if/then web to handle all possible input combinations, an ongoing first-operator variable that continuously updates as more complex equations are entered (this would be similar to how a basic 7-seg calculator would do it), an equation string that remembers all inputs and then coughs up a solution after hitting equals, a mix between those, another solution I would have never thought of, etc. Just need to re-think about the problem with these new challenges in mind, and decide how you’d like to solve it. Thats the fun part