Comments

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Comments

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

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

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1// This explains the code AA single-line comment ignored by JavaScript
2/* This spans multiple lines */ B// a helpful note
3Text meant for humans, not the computer C/* note more notes */
4Ignored across several lines of code DWrong - that's HTML syntax, not JavaScript
5-- This is a comment EA multi-line comment ignored by JavaScript
6<!-- This is a comment --> FWrong - JavaScript comments use //, not --

Definitions

//

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
__ This is a comment
2.
let x = 5; __ set x to 5
3.
__ Multi-line comment start
4.
End of comment __
5.
__ Ignored by JavaScript

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A -- This is a comment
B // Another comment
C let x = 5;
Question 2
A // A comment here
B ## Another comment
C let y = 10;
Question 3
A \ End of comment
B /* Start of comment
C still inside comment
Question 4
A let a = 1;
B // sets a to 1
C let b = 2; \\ sets b to 2
Question 5
A /* Opens comment
B middle of comment
C closes comment */
D let c = 3;

Answer Key

Comments
Section A: Quick Questions
Q1
B — Yes
Q2
A — Yes
Q3
A — No
Q4
A — No
Q5
B — Yes
Section B: Match the Pairs
Q1
// This explains the code → A single-line comment ignored by JavaScript
Q2
/* This spans multiple lines */ → A multi-line comment ignored by JavaScript
Q3
Text meant for humans, not the computer → // a helpful note
Q4
Ignored across several lines of code → /* note more notes */
Q5
-- This is a comment → Wrong - JavaScript comments use //, not --
Q6
<!-- This is a comment --> → Wrong - that's HTML syntax, not JavaScript
Section C: Definitions
Q1
// — Marks the rest of a line as a comment, which JavaScript ignores when running the code.
Section D: Fill in the Blanks
Q1
// This is a comment
Q2
let x = 5; // set x to 5
Q3
/* Multi-line comment start
Q4
End of comment */
Q5
// Ignored by JavaScript
Section E: Spot the Error
Q1
A — Single-line comments start with //, not --.
Q2
B — JavaScript comments never start with ##.
Q3
A — Multi-line comments close with */, not a single backslash.
Q4
C — Single-line comments use //, not \\.
Q5
D — This line is actually correct code, not the error.