@jsdisco I tried making a copy of input
into newInput
like you said, but it made storedValue
which I’m setting to a string version of it to always lag one number or operator behind currentValue
which I don’t like. So I put it back to const newInput = input;
.
Anyways. With what I have now, I just need 4 of the tests to pass: 9, 11, 12 and 13. The rest are all passing.
9:
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 3 + 5 * 6 - 2 / 4 should produce 32.5 or 11.5 as an
answer, depending on the logic your calculator uses
(formula vs. immediate execution)
AssertionError: The expression 3 + 5 * 6 - 2 / 4 should produce 32.5 or 11.5 as an
answer, depending on the logic your calculator uses
(formula vs. immediate execution)
When I try doing this manually, I get 32.5 as the answer. So I really need to know how I can get this test to pass.
11:
11. When the decimal element is clicked, a "." should append to the currently displayed value; two "." in one number should not be accepted
An input of "5 . 5 . 5" should display 5.55 : expected '55.5' to equal '5.55'
AssertionError: An input of "5 . 5 . 5" should display 5.55 : expected '55.5' to equal '5.55'
Again, trying this manually gives me 5.55 in the display. How do I get this test to pass?
12:
12. I should be able to perform any operation (+, -, *, /) on numbers containing decimal points
The expression "10.5 - 5.5" should produce an output of "5" : expected '5.5' to equal '5'
AssertionError: The expression "10.5 - 5.5" should produce an output of "5" : expected '5.5' to equal '5'
Trying this manually produces 5 as the answer. So how do I get this test to pass?
13:
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 '25' to equal '10'
AssertionError: The sequence "5 * - + 5" = should produce an output of "10" : expected '25' to equal '10'
This is the only one out of these it’s right about. I need help on getting this right and also on getting the test to pass.
GitHub repo is updated.
Please help me out with fixing the problems.
@lasjorg Did you try doing what tests 9, 11 and 12 are doing manually? When I do it I always get the right result. Hence my confusion. I also tried doing “123” and then clearing the display. No weird issues here. I should probably try logging the input array, but what handler(s) should I do it in?