Question 4
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const thermostat = {
_celsius: 22,
set celsius() {
this._celsius = 25;
},
};
thermostat.celsius = 30;
- A It sets _celsius to 30
- B SyntaxError: a setter must have exactly one parameter, which receives the assigned value Correct
- C It sets _celsius to 25
- D TypeError
Correct Answer: Option B
set celsius(value) { this._celsius = value; } – the assigned value is passed as the single argument.
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!