Tell us what’s happening:
i solved the challenge and it keeps telling ther’a a reference error :thermostat is not defined
how can this happen and how i can solve it ?
also it says these requirements are not fulfilled
Thermostat should be a class with a defined constructor method.
A getter should be defined.
A setter should be 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 ;
}
}
// 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(thermos)
Your browser information:
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: