Hey guys,
I’ve just watched Ivan’s video on “Loops in Javascript.” In it his loops fall one line below each other instead of one loooong line of outputs. As far as I can tell he achieves this by using headings (h1 and h2) and the + symbol. Could you elaborate on this?
Now, I’ve tried to loop my loops without headings, but try as I might I can’t get them to fall one beneath each other. This is the code I’ve written.
var textToDisplay = “Wazzup”;
for (var counter = 0; counter < 100; counter++) {
document.write(textToDisplay);
}
When I execute it I get a long line of Wazzups instead of one beneath the other. As soon as I wrap the variable in headings the code outputs one line beneath the other.
So I have two questions:
- Is there something magical about headings that makes the code execute on separate lines? (this question ties up with the one above)
and
- How can I write the code so that my outputs fall on separate lines without using headings?
I hope I made sense and thanks to anyone who can help me!
Regards
Emmerich