Tell us what’s happening: I was getting confused with this sentence in the challenge “In the class, create a getter
to obtain the temperature in Celsius and a setter
to set the temperature in Celsius”. I think it should be “… and a setter to set the temperature in Fahrenheit”
**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
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: