Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
var score = 40
score 5;
console.log(score);

What I have tried:

I have put assignment operators (+, -, and /) in the space between score and 5 as written above but I got wrong results.
Posted
Updated 30-Mar-23 21:19pm
Comments
Dave Kreskowiak 14-Jan-23 11:33am    
There is only one assignment operator, =

You haven't said what this little piece of code is supposed to do, so it's impossible to tell you what you're doing wrong.

The answer is
Var score = 40;
Score -= 5;
Console.log(score);
 
Share this answer
 
You need to actually use an assignment operator to change a value (or a "hidden assignment" such as a pre- or post- increment / decrement operator).
Try:
JavaScript
score = score - 5;
 
Share this answer
 
See JavaScript Operators[^] for all the details.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900