I am not sure why I cannot pass User Story #13. This is the error that I am receiving:
The sequence “5 * - + 5” = should produce an output of “10” : expected ‘0’ to equal ‘10’
When I press the buttons, “5 * - + 5 =”, I see an output of ‘10’ on the display, which is correct. But the test appears to see ‘0’ instead of ‘10’, and it won’t let me pass.
All of the other user stories pass, and the other User Story #13 test cases appear to pass the test. I would definitely appreciate any help. Thank you so much.
Here is a link to my Codepen: https://codepen.io/johnpham0527/pen/BaNwaNq
I have tried debugging my code, but I am still stumped. I believe that I may have discovered a bug in the test suite, so I have submitted a bug request: https://github.com/freeCodeCamp/testable-projects-fcc/issues/1055.
I found the problem. I have a variable that is tracking whether a digit is negative. That variable needs to be set to “false” after the equal button is pressed. Otherwise, the next sequence or calculation will be evaluated incorrectly.
Sorry, I shouldn’t have opened up a bug request. The flaw was in my code.
So, what I found is that with the sequence "5 * - + 5 = " you have you end up with an infinite loop at line 227 and CodePen stops the execution of the test before the display is updated. At this spot you have a condition that does a
while (newState.queue.length >= 3)
but by the time you get here the length of the queue is 1. I’ve executed the code both through the test and by clicking on buttons myself and the result is the same. Somehow, somewhere, in your code you are degrading your code to handle this exception, but the problem is it’s after the sequence that should have been triggered by the pressing of “=”.
Oh maybe I pulled down the new code after you fixed it. I thought i saw that problem but then it went away.
the loop thing was a miss read. it was exiting out because I had a pause inside the loop, not because of any infinite loop.
Thanks, chicocoder! I started to use the browser debugger today for the first. It was a good learning experience for me as well.