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 trialElizabeth Bazan
3,007 PointsThe Random Challenge: What does the <p></p> represent in var message? This is a paragraph tag in html. Confused....
What does the <p></p> represent in the var message? I know this only as a paragraph tag in html. How doe this work in JS?
2 Answers
philippulbrich
11,975 PointsHi Elizabeth, the <p> tag works like html. They are used for example if you want to output something from your js file in your html code. For example, in this notation
var message;
message ='<p>' + .... +'</p>';
You can also use other tags like <span> etc in js.
I hope I have been able to help you - Phil
philippulbrich
11,975 PointsThat works, of course. You don't have to use <p> tags. However, if you are using <p> etc you can use css to style them later. The <p> tags automatically use the way they are displayed - which is usually nicer. You can always check it out yourself if you use the workspace here on treehouse or with your own IDE. Just try out different ways and let them show you.
Best regards - Phil
Elizabeth Bazan
3,007 PointsElizabeth Bazan
3,007 PointsHi Phil, I ran the below and it seemed to work. Is this a case where many ways to generate the same result? var message = randomNumber + " is a number between 1 and " + topNumber + ". "; document.write(message);