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 Working with Strings Variables and Strings Challenge

Forrest Pollard
Forrest Pollard
1,988 Points

What does it mean in the instructions when it mentioned the "<p>" element?

I got the program to work just fine, but i was wondering what it meant with the 3rd step in the instructions in the workspace.

"Display the story as a <p> inside the <main> element."

as i didnt know what the <p> element was i just did the querySelector in the 'main' of the HTML and it worked but now im worried that i missed something and i havent learned what i was supposed to

Hi <p> is html tag which mean paragraph, like in last video he has used <h1> tag displaying the message.

2 Answers

The second step in the solution instructions uses a <p> element to display the variable:

// 2. Combine the input with other words to create a story.
const sentence = `<p>There once was a ${adjective} programmer who wanted to use JavaScript to ${verb} the ${noun}.</p>`;

If you didn't put this text in any kind of element at all, the page will work, but you'll be heavily limiting yourself on how well you can style your sentence, or even modify that section further with JavaScript.

The <p> element simply means paragraph. By default, it uses the browser's rules for paragraphs (being sectioned blocks of text), but those rules can be overwritten if necessary. It's simply a way to mark up your HTML to make it more readable and understandable, as well as give you a jump start on having your page work the way you want it to. If you aren't familiar with <p> and <div> elements, or even more specific markups such as <aside>, <header>, <footer>, etc. I'd suggest going back over the HTML basics videos in the Web Development track.

Forrest Pollard
Forrest Pollard
1,988 Points

Thanks so much for the helpful answer. As it turns out i haven't done any of the HTML basics at all I wanted to just do Java and Javascript. I'll go over the HTML basics too :)

Yeah, as long as you have a basic understanding of what HTML looks like, you'll be able to pick on on modifying HTML with JavaScript pretty easily. HTML is very easy to learn, but it can be hard to make sense of if you don't know what you're looking at.

Just a heads up if you aren't already aware, Java and JavaScript are not very similar despite having very similar names. Knowing both of them certainly won't be an issue; the more languages you know the better. They just don't have very similar contexts. C# is actually very similar to Java, but is more commonly used for web application development. So if that's what you're into, I'd definitely recommend C#.

Thanks for the answer. and the insight it helped me too.