+ 2

How to fix my javascript command?

All works good but my var is the problem.. why does javascript don't accept it how i wrote it? i just need answers to my var x=x; ... document.write(x); https://code.sololearn.com/WzwydtdroxPF/?ref=app

27th May 2017, 7:30 PM
TrueJu
TrueJu - avatar
4 RĂ©ponses
+ 3
I ran your code from the link above and there were a couple of errors present. First of all at the beginning of your for loop, you did not declare i a variable. Corrected code is below and it works now. Current State: for ( i=1; i<=100; i++) { document.write(i + "<br />"; } Corrected Code: for (var i = 1; i <=100; i++) { document.write(i + "<br />"); }
27th May 2017, 8:09 PM
Jeff Rice
Jeff Rice - avatar
+ 2
omg that rookie bad from me :( thank you so much !
27th May 2017, 7:35 PM
TrueJu
TrueJu - avatar
+ 2
ok thank you
27th May 2017, 8:13 PM
TrueJu
TrueJu - avatar