LearnFrenzy
Sign in Take a free test

JavaScript Basics · Find the Error · Question 6

Error: commenting out code that has a comment Answer, explanation & discussion

  • Find the error
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 6 Back to Exercise

JavaScript refuses to run the code below. Which statement correctly describes the problem?

main.js
/*
let tax = 0.18; /* GST rate */
let total = 100 * (1 + tax);
*/
console.log("Billing disabled");
  • A SyntaxError: block comments do not nest – the first */ ends the comment and the final */ is invalid code Correct
  • B It prints Billing disabled
  • C ReferenceError: tax is not defined
  • D Only the GST rate comment is removed
Correct Answer: Option A

The comment ends after GST rate */. The next line is normal code and the lone */ at the end is a SyntaxError. Comment out code with // on each line instead.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links