myVar++ not acceptable?

Found a flaw in the following topic:
In the “Increment a Number with JavaScript”: When I change the statement to myVar++ it keeps saying “You should not use the assignment operator.” Help please. Thanks.

Please provide a link to the challenge and cut and paste all of the code you are submitting so we can have a look.

If I found the correct challenge, I was able to complete it with the ++ operator. To help you, we’d need to see the entirety of your code.

Here is a picture.

Next time please post actual code (not an image) AND a link to the challenge.
Anyway, I tested it, got the same error, added a semicolon at the end, then it passed.
Sooo: add a ; at the end and give us an update if it worked.

OK, good catch.

Yeah, technically the semicolon shouldn’t be required according to JS (which will automatically add them in as you compile). But I guess the test is expecting them because they’ve been using explicit semicolons up to that point.

The whole semicolon/no-semicolon things is one of my pet peeves about JS. Just make a choice.

Yeah, in the future, the Get Help -> Ask for Help button will post a question, provide a link, and share your code for you.

1 Like

O my bad. Thanks I should’ve gotten that one!

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