Comments, online

Six activities your students do on their own devices. See who's finished, and their scores.

Comments in one minute

What students need to know

Comments explain code without affecting how it runs. Multi-line comments can span as many lines as needed.

// tells JavaScript to ignore the rest of that line. Everything between /* and */ is ignored, even across lines.

Mistakes students make

  • Single-line comments start with //, not --.
  • JavaScript comments never start with ##.
  • Multi-line comments close with */, not a single backslash.
  • Single-line comments use //, not \\.

Discover other journeys with this module

What students will learn in this module

Every question in Module 2

Quick questions

  1. Does // start a single-line comment?ANoBYes
  2. Does /* */ wrap a multi-line comment?AYesBNo
  3. Is -- a valid way to start a comment in JavaScript?ANoBYes
  4. Does JavaScript run the code inside a comment?ANoBYes
  5. Can you put a comment on the same line as code?ANoBYes

Key terms

Students type the meaning of:

  • //

Match the pairs

// This explains the codeMatch it to what it does
/* This spans multiple lines */Match it to what it does
Text meant for humans, not the computerMatch it to what it does
Ignored across several lines of codeMatch it to what it does
-- This is a commentMatch it to what it does
<!-- This is a comment -->Match it to what it does

Fill in the blanks

  1. __ This is a comment

    Hint: Type the symbol that starts a single-line comment.

  2. let x = 5; __ set x to 5

    Hint: Type the symbol that starts a single-line comment.

  3. __ Multi-line comment start

    Hint: Type the symbol that opens a multi-line comment.

  4. End of comment __

    Hint: Type the symbol that closes a multi-line comment.

  5. __ Ignored by JavaScript

    Hint: Type the symbol that starts a single-line comment.

Spot the error

Question 1

A-- This is a commentB// Another commentClet x = 5;

Question 2

A// A comment hereB## Another commentClet y = 10;

Question 3

A\ End of commentB/* Start of commentCstill inside comment

Question 4

Alet a = 1;B// sets a to 1Clet b = 2; \\ sets b to 2

Question 5

A/* Opens commentBmiddle of commentCcloses comment */Dlet c = 3;