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) Storing and Tracking Information with Variables The Variable Challenge Solution

Meg Cusack
Meg Cusack
11,448 Points

Quote marks outside of the H2 tags?

In the variable challenge, what is going on with his first line of code where he has quote marks outside of the H2 tags? He hasn't talked about that yet.

1 Answer

Aaron Loften
Aaron Loften
12,464 Points

Fantastic question. It's a string that isnt assigned anywhere. Meaning, it's useless. He is using it like a comment to himself in the code that will not appear to the user. Honestly, I think he was wrong to do this.

The first line is a string. However, it is not assigned to a variable, not being used anywhere, and doesnt show up on the page. It also looks like an accident to a stranger.

Personally, I feel this is "bad practice." This means we shouldnt do things this way because they could cause errors in some scenarios or confusion.

A better way to have done this would be with a comment.

eg:

//this is a comment that counts as a note to the developer.
var note = "Read the comment in the file, because the comment wont appear on the page to a user.";

Infact, when typing in the string he wrote, I recieved an error on my editor.

Though it shouldnt, in theory, hurt to write random strings everywhere, you should avoid it since it could cause disorganization and confusion in the code. :)

Good job asking questions like this. It helps to question things that dont look right.

Meg Cusack
Meg Cusack
11,448 Points

Thanks, Aaron! That is a very helpful (and quick) answer! I was definitely confused by that being there and agree that it would have been much more helpful for him to identify it as a comment.