I am trying to solve this challenge but somehow its not working the setter method is still saying that its not setting the new value of Celsius to Fehrenheit can anyone help
**class Thermostat {
constructor(fahrenheit) {
this._fahrenheit = fahrenheit;
}
//Getter
get temperature() {
return (5/9) * (this._fahrenheit - 32);
}
//Setter
set temperature(updateTemperature) {
this._fehrenheit = (updateTemperature * 9.0) / 5 + 32;
}
}**
// Only change code below this line
class Thermostat {
constructor(fahrenheit) {
this._fahrenheit = fahrenheit;
}
//Getter
get temperature() {
return (5/9) * (this._fahrenheit - 32);
}
//Setter
set temperature(updateTemperature) {
this._fehrenheit = (updateTemperature * 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
console.log(thermos.temperature)
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_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Safari/605.1.15
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: