Javascript Calculator Failed Test#9 But APP Gives Correct Result

Tell us what’s happening:
I am working on the JS calculator project and don’t understand why my test case #9 failed.

User Story #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 .

In the test description, it said “The expression 5 - 9 + 5 should produce a result of 1.” I tested typing the expression and it returns 1 to the display.

Appreciate any pointers on this one. Thanks

Your code so far
I deployed the app to netlify with below link:

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Front End Development Libraries Projects - Build a JavaScript Calculator

Link to the challenge:

hello and welcome back to fcc forum :slight_smile:

can you also share codebase for it? bu on a hunch i would say, maybe you can try looking into this part

correct result should be shown in the element with the id of display

happy learning :slight_smile:

Thank you. I think I already have #display for the result div. It is on line 106. I think the issue could be a race condition where the test doesn’t wait until the result is shown before checking it. It could be because of the format of my result. e.g: whites spaces in between.

Looks like an issue on how the test captures result value. Switching the way react render fixes the issue.

Please refer to this post solution - Build a JavaScript Calculator - tests won't pass - #5 by RandellDawson

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