Question 8
Back to Exercise
The code below stops with an uncaught error. Which statement correctly describes the problem?
const orderId = Symbol("order-42");
console.log("Processing " + orderId);
- A TypeError: a Symbol cannot be converted to a string implicitly – use orderId.toString() or orderId.description Correct
- B It prints Processing Symbol(order-42)
- C It prints Processing order-42
- D It prints Processing undefined
Correct Answer: Option A
Symbols refuse implicit string conversion so they are not accidentally used as text. String(orderId) or orderId.toString() gives "Symbol(order-42)"; orderId.description gives "order-42".
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!