x = 1;
if(x = 10) {x = 1;}
else {x = x + 1;}
alert (x);
The result is always 1, instead of 1,2,3...
Replace
if(x = 10) {x = 1;}
with
if(x == 10) {x = 1;}
Because x=10 returns 10, which in a test evaluates as true, and thus the code {x = 1;} is executed.
From the MDN about if...else :
Any value that is not undefined, null, 0, NaN, or the empty string (""), and any object, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement