0
Can someone tell me why this code outputs 6
var x=3; var i=0; while(i<3){ x+=1; i+=1; }; document.write(x);
4 Antworten
+ 3
At the beginning x = 3. You go through the loop 3 times and you add 1 to x each times. So finally you have done x = x + 3 = 3 + 3 = 6...
Does that help or should I explain another way?
+ 2
Here. Check out this code. Go to the JS tab and read the comments. ☺
https://code.sololearn.com/WO078f1wyUSp/?ref=app
+ 1
Sure ☺
+ 1
ahh thanks man it realy helped😀