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 trialSwedina Yolanda
931 PointsCan I just write document.write('<p>Sorry, the number was</p> ' + randomNumber); ?
Is it really necessary to put the closing tag in the end, since there is no string after the var randomNumber?
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! It depends entirely on how you want it to look on the page. In the example, the closing <p>
tag was included after the random number so that the random number will appear as a part of the "block". Most browsers implement the paragraph with a default of display: block;
. This includes a small margin above and below it. Also, had you styled your paragraphs, the random number would not inherit those styles, but rather the styles applied to the body. Ultimately, your way would work too, but it depends entirely on how you want it to look.
Antonio De Rose
20,885 PointsAntonio De Rose
20,885 Pointscould you post, the whole of code, covering the randomNumber variable too.