Assignment operator

I want problem in assignment operator in java script-

//Assignment operator
let assignment = 1;
assignment + = 1
console.log(assignment)

Hey, @DevrajMahajan1 welcome to the forums!

What do you need help with exactly?

Welcome to Ask, @DevrajMahajan1.

There are a few bugs in your code.

let assignment = 1; // Correct.
assignment += 1; // You put a space between + and = (it won't work, you can't have a space) and you forgot the semicolon.
console.log(assignment); // You forgot the semicolon again.

If you need any more help, please ask. Otherwise, this should be helpful.

Even if programs dont have semicolons (in JS) almost if not every modern interpreter will run it just fine.

1 Like

Guess I learned something new today. I always thought you needed it, but isn’t having a semicolon good practice?

2 Likes

Coding teacher here says :+1: but @not-ethan is right many interpreters help you out if you forget.

3 Likes