DEV Community

Muhammad Akil
Muhammad Akil

Posted on

Comment Your JavaScript Code

Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.

There are two ways to write comments in JavaScript:

Using // will tell JavaScript to ignore the remainder of the text on the current line. This is an in-line comment:

// This is an in-line comment.

You can make a multi-line comment beginning with /* and ending with */. This is a multi-line comment:

/* This is a
multi-line comment */

NOTE: As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others and for your future self.

You should create a // style comment that contains at least five letters.

The answer

// This is an in-line comment.
Enter fullscreen mode Exit fullscreen mode

You should create a /* */ style comment that contains at least five letters.
The answer

/* This is a
multi-line comment */
Enter fullscreen mode Exit fullscreen mode

Top comments (0)