Front End Development Libraries Projects - Build a JavaScript Calculator

Tell us what’s happening:
I’m having trouble locating the issue in my code to pass test 13 on the javascript calculator when entering 5*-5 the negative operator clears out my input and results in the answer -5 instead of -25 a link to my codepen for this project is below
Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

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

Link to the challenge:

At first glance, the “negative-value” thing doesn’t really seem to exist. All I can tell is that at present, it’s impossible to multiply by a negative number right now. For the first number it’s fine. The second you got to watch out for.

any ideas on how to fix it?

1 Like

When you enter a negative value using the “negative-value” button, you’re checking for the presence of “-1” in the display string, which is not what you want. Instead, you should be checking for a minus sign (“-”) to determine if the number is negative or not.
If there is no minus sign, add a minus sign at the beginning of the display content
( making the number negative).
If there is already a minus sign present in the display content
remove the minus sign (make the number positive).

1 Like

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