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 JavaScript Basics (Retired) Making Decisions with Conditional Statements Build a Random Number Guessing Game

Swedina Yolanda
Swedina Yolanda
931 Points

Can 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?

Antonio De Rose
Antonio De Rose
20,885 Points

could you post, the whole of code, covering the randomNumber variable too.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi 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.