Cannot pass Test 11 on JS calculcator

My code can be found here: https://codepen.io/John-Sweetnam/pen/mdZQdmY?editors=1111

I can’t figure out what the issue is. The test is supposed to detect incorrect decimal places but when I test it myself, everything seems to be working correctly. Even the listed example in the test details ‘An input of “5 . . 0” should display 5.0 : expected ‘05.0’ to equal ‘5.0’’, seems to be working fine when I type it in by hand. The only potential issue I could see is that the answer is displayed as 5 instead of 5.0, but it looks the same in the example project given on the test page.

I just can’t figure out what is causing the test to fail.

Hi there!

Post a link to the curriculum challenge and your code here.

I included a link to my code above but here it is again.
Here is the project challenge page.

Any help would be greatly appreciated.

You need to use Help button to create a topic to the challenge project. That button appears below the challenge editor when you try to submit the wrong code more than three times.

Ok, I’ll repost. Do I put in general category?

You didn’t need to chose the category, when you using the Help button. It will automatically create a topic to the appropriate category.

Tell us what’s happening:

I cannot get my code for the JS calculator to pass test 11 and I don’t know why. My calculator does not allow multiple decimals and typing in the test case by hand works when I do it. Test is still registering as failing. Has anyone encountered an issue like this, or know how to get more detail on exactly how this is being tested?

Your code so far

Link to my code

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0

Challenge Information:

Front End Development Libraries Projects - Build a JavaScript Calculator

Please do not create duplicate topics for the same challenge. I have merged your threads.

Ok. I wasn’t sure how to close this one after I was told to open another. Thanks!

This is the test output.

An input of “5 . . 0” should display 5.0 : expected ‘05.0’ to equal ‘5.0’

Which is the same I see in the display element when I type 5 . . 0

I assume you have to make sure your display element is using the same value as your formula does (I didn’t look at the code).


There seems to be an issue with the clear function. If I press clear and then type a number, it will have 0 in front of it.

Hey, solved it!

Thanks for mentioning the dangling 0 issue. once I pulled on that thread, I resolved the other issues as well. Turns out there was an issue where I was checking for ‘0’ when it could be 0 or the string ‘0’. Once I found that, I found a potential issue with my AC button not fully resetting all the state variables it needed to. Then, on the next run through, all tests passed.

Thanks again!!!