Tell us what’s happening:
Hi, i keep getting the " Thermostat should be able to be instantiated." error, i don’t know what the problem could be, i saw that people on forums say that the temperature conversion should be on the getter, or the setter, or the constructor.
But not on all of them.
I’d appreciate any help.
Your code so far
// Only change code below this line
class Thermostat {
constructor(temp) {
this._temp = temp
}
//getter
get temperature(){
return 5/9 * (this.temp - 32);
}
//setter
set temperature(value){
this._temp = 5/9 * (value - 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; rv:81.0) Gecko/20100101 Firefox/81.0
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: