Question 8
Back to Exercise
The code below stops with an uncaught error. Which statement correctly describes the problem?
try {
JSON.parse("{invalid}");
} catch (e) {
console.log("Problem: " + e.message.toUppercase());
}
- A It prints the message in capitals
- B SyntaxError from JSON.parse is uncaught
- C It prints Problem: undefined
- D TypeError: toUppercase is not a function (it is toUpperCase) – an error thrown inside catch is not caught by the same try Correct
Correct Answer: Option D
The catch handled the SyntaxError, but then threw a new TypeError, which escapes.
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!