Question 12
Back to Exercise
The code below stops with an uncaught error. Which statement correctly describes the problem?
const pi = 3.14;
console.log("Area:", pi * 2 * 2);
pi = 3.14159;
console.log("Area:", pi * 2 * 2);
- A SyntaxError before anything is printed
- B It prints both areas
- C It prints the first area, then TypeError: Assignment to constant variable Correct
- D ReferenceError: pi is not defined
Correct Answer: Option C
Reassigning a const is a run-time TypeError, so the first line runs and prints Area: 12.56. Use let if the value must change.
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!