Multiple choice

What is the correct syntax for adding comments in JavaScript?

  1. <!–This is a comment–&gt

  2. //This is a comment

  3. –This is a comment

  4. This is a comment

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In JavaScript, single-line comments are written using double forward slashes '//'. Any text following '//' on the same line is ignored by the JavaScript engine.