JavaScript Comments

Comments are used to explain JavaScript code. Comments are not executed by the JavaScript interpreter, so they do not affect the behavior of the code.

There are two types of comments in JavaScript:

  • Single-line comments: Single-line comments start with two forward slashes (//) and end at the end of the line.
  • Multi-line comments: Multi-line comments start with /* and end with */.

Here are some examples of JavaScript comments:

// This is a single-line comment

/*
This is a multi-line comment
that spans multiple lines.
*/

Task

Use comments to make the below code more readable and to clarify your intentions.


				
ADVERTISEMENT
ADVERTISEMENT