Tell us what’s happening:
I am trying to complete the lesson ’ ES6: Use getters and setters to Control Access to an Object’ but I am getting an error that reads:
Thermostat should be able to be instantiated.
Can someone explain to me what this means? I have looked through various forum posts on this same topic but no one has mentioned instantiation. My understanding is that it refers to being able to copy the class to create a new object but I can’t see what I would need to change to enable something like that. Any direction or information would be greatly appreciated, this is my first post so please just let me know if there is anything else I should add.
Your code so far
// Only change code below this line
class Thermostat {
constructor(F) {
this._F = F;
}
get temperature() {
return (5/9) * (this.F - 32);
}
set temperature(C) {
this.F = (C * 9.0) / 5 + 32;
}
}
// Only change code above this line
const thermos = new Thermostat(76); // Setting in Fahrenheit scale
let temp = thermos.temperature; // 24.44 in Celsius
thermos.temperature = 26;
temp = thermos.temperature; // 26 in Celsius
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: