Tell us what’s happening:
I dont understand why I cant proceed. I even copy the whole thing from the solution and it return error.
Thermostat should be a class with defined constructor method
Thermostat should be able to be instantiated
A getter should be defined
A setter should be defined
Reference error: temperature is not defined
Your code so far
// Only change code below this line
class Thermostat {
constructor(fahrenheit) {
this.fahrenheit = fahrenheit;
}
get temperature() {
return (5 / 9) * (this.fahrenheit - 32);
}
set temperature(celsius) {
this.fahrenheit = (celsius * 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
console.log(temperature);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.54
Challenge: ES6 - Use getters and setters to Control Access to an Object
Link to the challenge: