+ 2
In loops, anyone explain in details to me this line of code. document. write(i+ "<br>"); I understood the rest part just this 1
Loops in JavaScript
8 odpowiedzi
+ 8
You should have tagged JavaScript on your question. I'm guessing it makes the value of i a string and concatenates the specified string together, giving "1<br />" through "5<br />". However, I haven't studied JavaScript as yet.
+ 3
could you share entire code?
+ 2
Thanks in advance
+ 2
Here we go.
for (i=1; i<=5; i++) {
document.write(i + "<br />");
}
+ 2
It is a loop to show numbers from 1 to 5, each one in a new line because <br/> at the end is to jump next line
+ 2
OK what about the i+ in the bracket?
+ 2
Thanks John
+ 1
document.write(i + "<br>")
i guess the part confusing you is the html break line tag<br>. that is just a way of telling the browser to display every new result in a new line.
try removing the "<br>" (include the quotes) and see how everything would compact together