Comments, online
Six activities your students do on their own devices. See who's finished, and their scores.
Learning
Understanding
Testing
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 \\.
PREVIOUS · MODULE 1console.log()
YOU ARE HERE · MODULE 2Comments
NEXT · MODULE 3Variables: let, const, var
What students will learn in this module
Every question in Module 2
Quick questions
- Does // start a single-line comment?ANoBYes
- Does /* */ wrap a multi-line comment?AYesBNo
- Is -- a valid way to start a comment in JavaScript?ANoBYes
- Does JavaScript run the code inside a comment?ANoBYes
- 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 doesText meant for humans, not the computerMatch it to what it doesIgnored 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 doesFill in the blanks
__ This is a comment
Hint: Type the symbol that starts a single-line comment.
let x = 5; __ set x to 5
Hint: Type the symbol that starts a single-line comment.
__ Multi-line comment start
Hint: Type the symbol that opens a multi-line comment.
End of comment __
Hint: Type the symbol that closes a multi-line comment.
__ 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;
