But I don’t understand why. Why wouldn’t my code below work? Just want some explanation cause it feels like I am missing something.
Wouls greatly appreciate your help! <3
**Your code so far**
// Only change code below this line
class Thermostat {
constructor(fahrenheit){
this.fahrenheit = fahrenheit;
}
get temperature(){
const inCelcius = 5/9 * (this.fahrenheit - 32) ;
return inCelcius;
}
set temperature (temperatureInCelcius){
this.fahrenheit = temperatureInCelcius;
}
}
// Only change code above this line
const thermos = new Thermostat(76); // Setting in Fahrenheit scale
let temp = thermos.temperature; // 24.44 in Celsius
console.log(temp);
thermos.temperature = 26;
temp = thermos.temperature; // 26 in Celsius
console.log(temp);
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0
Challenge: Use getters and setters to Control Access to an Object