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) Working With Numbers The Random Challenge Solution

Jesus Bayona
Jesus Bayona
4,937 Points

Are the html tags necessary?

Why do you have to use the "(p)(/p)" html tags in there? Wouldn't it work just as well without it? I attempted to post the actual tags but they're not displaying, so I'm using () instead of what's normally used.

2 Answers

Hi,

Now i got the question. The code will work without the paragraph tag.

It is just for an alignment and view of the string. If we use a paragraph tag,"Browsers automatically add some space (margin) before and after each <p> element.". We can ignore it if we want.

Thanks, Aishu

Hi,

The use of double quotes("") means they are javascript strings. In case if you ignore the double quotes, it will be considered as a variable/object.

For eg:
var name = "xxx":
console.log(name); ---> prints xxx;
console.log("name"); ---> prints name;

you can also go through the topic javascript strings which will give lot of info on it. please let me know if it clarifies your doubt.

In the video, paragraph tag is assigned to the variable message. In case if you ignore the double quotes there, it will consider it as a variable and will search for its value. Try to execute with and without strings which will give a clearer picture.

message = "<p>";

thanks, aishu

Jesus Bayona
Jesus Bayona
4,937 Points

Sorry Aishu, I edited the question to reflect what I was trying to say. I didn't realize the interpreter removed what I had in the quotes.