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 Treehouse Club - MASH MASH - JavaScript The Structure of Functions

Casiey Lebron
Casiey Lebron
3,187 Points

Single line/Multi-line comments

In what instances can we use these comments, Can they replace out paragraphs, titles and text written on html pages?

2 Answers

Tommy Choe
Tommy Choe
38,156 Points

Hey Casiey, comments can be used anytime you want to annotate or make a note in your code. Anything that is placed after/inside of the comments aren't read by the compiler. So they can "replace out" paragraphs, titles, and texts.

Hope that answers your question.

LaVaughn Haynes
LaVaughn Haynes
12,397 Points

Tommy is correct. Another good use is when you think part of your code might be causing or will cause problems. You can use single or multi-line comments to comment it out for testing purposes. For example, if some value in my code depends on a complex function...

var answer = executeComplexFormula();

you comment out that line and set a specific value to test your code

//see what happens if a certain value is returned
//var answer = executeComplexFormula();
var answer = 17;
Casiey Lebron
Casiey Lebron
3,187 Points

Awesome... thank you both!