+ 2

I think it's wrong loop? But here I will meet this

var x=1; for (x; x < 10; i++) {} x+=x+100; document.write(x);

29th Apr 2017, 9:01 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
10 ответов
+ 8
put the" }" after document.write(x) like this document.write(x) } and your good. https://code.sololearn.com/Wm8bDQ7277qu/?ref=app
29th Apr 2017, 9:11 PM
Manual
Manual - avatar
+ 2
var x=1; for (x; x < 10; i++) {} x+=x+100; document.write(x);
29th Apr 2017, 9:14 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
sorry guys I mix code I want to know about this code
29th Apr 2017, 9:14 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
i=0 x=1 i=1 x=2 i=2 x=4 i=3 x=7 i=4 x=11 i=5 x=16 i=6 and that's it, because 6 is not less than 6, its equal :) so x is 16 :)
29th Apr 2017, 9:15 PM
Nikola Stojiljkovic
Nikola Stojiljkovic - avatar
+ 2
yes but this code I meet in javascript question here)) lol
29th Apr 2017, 9:22 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
I understand ok
29th Apr 2017, 9:29 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
I deleted the code because don't look which in code two x but thx guys
29th Apr 2017, 9:29 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
0
this code will add each i from 0 to 5 to x that is already set to 1. so x will be 16. if you wanted to do this then your code is ok
29th Apr 2017, 9:09 PM
Amar
Amar - avatar
0
@Kristina that code will create infinite loop of doing nothing. because var i is incrementing and x stays 1 and will never get >= 10. however, there is no code betw parentheses so it will do nothing - forever
29th Apr 2017, 9:21 PM
Amar
Amar - avatar
0
x will increment 9 times bcz of loop, and will become 10. so x+=x+100 is x=x+x+100 which means x is 120
29th Apr 2017, 9:27 PM
Amar
Amar - avatar