+ 2
Could someone explain me how this code works line to line? Thanks.
var x=1; for(x;x<10;x++){} x+=x+100; document.write(x);
1 Réponse
+ 3
The for loop will increase the value of x by 1 each iteration of the loop exiting the loop when x<10 is false. So, when x is equal to 10 the condition will be false, meaning the value of x will be 10 when the loop ends.
x+=x+100
is the same as
x = x + (x + 100)
x = 10 + (10 + 100)