Multiple choice technology databases

How can you add a comment in a JavaScript?

  1. <!--This is a comment-->

  2. 'This is a comment

  3. //This is a comment

  4. /*This is a comment */

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

Single-line comments in JavaScript begin with two forward slashes (//). Option A uses HTML comment syntax which doesn't work in JavaScript, option B uses a single quote which is for string literals, and option D shows multi-line comment syntax (which works but isn't the standard single-line approach).