X + x = x - wont work!

why doesnt x+ x = x work?

my compiler wont let me compile my code!!! is it a bug???

Have you put it into your developer tools console? I tells you right there. Because you have an invalid left-hand side of an assignment operator. Remember that = in programming is for assignment not the same thing as in math. You are essentially saying here that you want to take “x” and assign it to “x + x”. Which doesn’t make sense.

3 Likes

If the user is, as Martyr is surmising, trying to assign a value to x but doing it backwards, x = x+x will work every time - it’s doubling the value of x.

Well spotted, so easy to miss that. I certainly did.