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 trialJessica Stocks
2,934 PointsWhy is the indentation of document.write() methods like that after while()?
The first document.write() is aligned with while() but the next document.write() is not indented and so it aligns with the do loop itself. Why is that? Since both document.write methods are outside of the code block and while condition argument I would think they should both be aligned with the do loop since they are not nested.
1 Answer
Steven Parker
231,275 PointsMy guess is that it ws unintentional. The editor probably auto-indented the first one, mistaking the kind of loop.
The editor misunderstanding can probably be avoided by putting a semicolon at the end of the "while" expression, which I would consider a "best practice" anyway.