JavaScript: Comments

Almost every programming language allows you to add comments to your code. Interpreter doesn't evaluate comments, their only purpose is to give programmers opportunity to leave notes for themselves and others. There are two types of comments in JavaScript:

Single line comments start with //. Any text or symbols that follow, won't be evaluated or executed.

A comment can take up the whole line:

// For Winterfell!

or can follow some code on the same line:

console.log('I am the King'); // For Lannisters!

Multiline comments start with /* and end with */. Each line between them should start with the *.

 * The night is dark and
 * full of terrors.
console.log('I am the King');


Create a single line comment with the folowing text: You know nothing, Jon Snow!.


  • Comment - "A comment is just a text and it doesn't affect program execution. Programmers use it to add notes for themselves and for their colleagues"

    // single line comment

    * multiline comment
    * multiline comment

If you got stuck and don't know what to do, you can ask a question in our huge and friendly community