Which of the following is the correct syntax for a single-line comment in JavaScript?
A
// This is a comment B
# This is a comment C
<!-- This is a comment --> D
/* This is a comment */
Analysis & Theory
`//` is used for single-line comments in JavaScript.
Which of the following is used for multi-line comments in JavaScript?
A
// This is a comment B
# This is a comment C
/* This is a comment */ D
<!-- This is a comment -->
Analysis & Theory
`/* ... */` is used for multi-line comments in JavaScript.
What happens if you forget to close a multi-line comment?
A
It gives a warning B
The rest of the code becomes a comment C
It still runs normally D
It highlights the comment
Analysis & Theory
If a multi-line comment is not closed with `*/`, the rest of the code is treated as a comment, causing errors.
Can you place a comment at the end of a line of code?
A
Yes, using // B
No, comments must be on their own line C
Only with /**/ D
Only inside strings
Analysis & Theory
You can use `//` at the end of a line of code to write a comment.
Which of the following is NOT a valid comment in JavaScript?
A
// This is valid B
/* This is valid */ C
# This is not valid D
/* Multiline
Comment */
Analysis & Theory
`#` is used in Python, not JavaScript, so it's not valid here.