Question 14
Back to Exercise
The code below runs without an error, but its result is wrong. Which statement correctly identifies the bug?
const settings = { volume: 50, muted: false };
let { volume } = settings;
volume += 10; // turn it up
console.log("Saved volume:", settings.volume);
- A Destructuring copies the value into a new variable; changing volume does not change settings.volume – assign settings.volume += 10 Correct
- B let variables cannot be changed
- C volume must be declared with const
- D += does not work with numbers from objects
Correct Answer: Option A
The variable and the property are independent after destructuring (for primitives). Update the object itself, or create a new one: { ...settings, volume: volume }.
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!