Question 8
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("// not a comment"); // a real comment
console.log("/* also text */");
- A /* also text */
- B // not a comment /* also text */ Correct
- C Nothing is printed
- D // not a comment // a real comment /* also text */
Correct Answer: Option B
Inside a string literal, // and /* are ordinary characters. Only the // after the statement starts a comment.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!