Question 5
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const settings = { volume: 7 };
const { volume: 10 } = settings;
console.log(volume);
- A It prints 7
- B It prints 10
- C SyntaxError: after the colon must come a variable name (or pattern) – a default is written with =: { volume = 10 } Correct
- D ReferenceError
Correct Answer: Option C
In { prop: target }, the target must be a binding. To give a default, use = instead of :, or both: { volume: vol = 10 }.
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!