Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

document.write printing on web page

I was just fiddling around with this loop, my question is why does it keep printing to the web page horizontally and other times vertically?

var counter = 1; while ( counter <= 1000000 ) { document.write(counter); counter += 1; }

1 Answer

My assumption would be that there is a max-width for an HTML page and when that limit is hit it may loop and continue on to the next line or weird behavior may occur.

This is an interesting question, and one which I don't have an answer but I thought I would chime into the conversation.