Tell us what’s happening:
I cannot see the reason why this does not work. It keeps saying the getter and setter need to be defined, and it is already, just like the example.
Your code so far
// Only change code below this line
class Thermostat {
constructor(tempF) {
this.tempF = tempF;
}
get temp() {
return 5/9 * (this.tempF - 32);
}
set temp(tempC) {
this.tempF = (tempC * 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 (Macintosh; Intel Mac OS X 11_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: