Comments

Hey ,

I'm thrilled to help you learn JavaScript. Unfortunately, you've landed on a page where you cannot access with your current purchase.

Please upgrade (use this link) access this content.

I'm super eager to help you learn more!

Comments

You can write additional notes to help you think through problems in JavaScript. To write these additional notes, you use comments.

Comments appear in two forms:

  1. //
  2. /* */

Commenting with //

You can write comments in JavaScript by adding double slashes (//). Anything after // is commented and will not be run by JavaScript.

// This is a comment

You can write // comments anywhere in your code, even in the middle of a line, like this:

const tables = 4 // 4 tables in the room

For the purpose of this course, whenever I console.log a variable from this point onwards, I would also write a comment that shows you what is printed in the console, like this:

console.log(44) // 44

Commenting with /* */

You can also write comments with the /* */ syntax. Any words between /* and */ is a comment.

/* This is a comment */

You can write comments that span multiple lines if you use /* */:

/*
  Everything
  is
  commented
  in
  this
  example.
*/