← JavaScript

Comments

Marks the rest of a line as a comment, which JavaScript ignores when running the code.

Understanding Comments in JavaScript

What it does: 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. JavaScript comments use // or /* */, never --. A // comment can follow code on the same line. <!-- --> is HTML syntax, not JavaScript. Without */, the comment never properly closes.

Common mistakes: Single-line comments start with //, not --. JavaScript comments never start with ##.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 1–10) and word search (Modules 1–29).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Does // start a single-line comment?
YesNo
Matches
-- This is a comment
↓
Wrong - JavaScript comments use //, not --
Applying
Meanings
Term
//
Meaning
Marks the rest of a line as a comment, which JavaScript ignores when running the code.
Practice
// This is a single-line comment
Testing
Gaps
This is a comment
Check Answer
Spots
1-- This is a comment
2// Another comment

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Scorpion' badge — Venom Debugger, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Does // start a single-line comment?
A. No
B. Yes ✓
// tells JavaScript to ignore the rest of that line.
2. Does /* */ wrap a multi-line comment?
A. Yes ✓
B. No
Everything between /* and */ is ignored, even across lines.
3. Is -- a valid way to start a comment in JavaScript?
A. No ✓
B. Yes
JavaScript comments use // or /* */, never --.
4. Does JavaScript run the code inside a comment?
A. No ✓
B. Yes
Comments are ignored entirely when the code runs.
5. Can you put a comment on the same line as code?
A. No
B. Yes ✓
A // comment can follow code on the same line.

Match the Pairs

// This explains the code → A single-line comment ignored by JavaScript
/* This spans multiple lines */ → A multi-line comment ignored by JavaScript
Text meant for humans, not the computer → // a helpful note
Ignored across several lines of code → /* note more notes */
-- This is a comment → Wrong - JavaScript comments use //, not --
<!-- This is a comment --> → Wrong - that's HTML syntax, not JavaScript

Key Term

//
Marks the rest of a line as a comment, which JavaScript ignores when running the code.

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 comment
B // Another comment
C let x = 5;
Line A — Single-line comments start with //, not --.
Question 2
A // A comment here
B ## Another comment
C let y = 10;
Line B — JavaScript comments never start with ##.
Question 3
A \ End of comment
B /* Start of comment
C still inside comment
Line A — Multi-line comments close with */, not a single backslash.
Question 4
A let a = 1;
B // sets a to 1
C let b = 2; \\ sets b to 2
Line C — Single-line comments use //, not \\.
Question 5
A /* Opens comment
B middle of comment
C closes comment */
D let c = 3;
Line D — This line is actually correct code, not the error.

Student with a class code? Join your class →