class Thermostat {
constructor(F = (C * 9.0 / 5 + 32)) {
this.thermos = F;
}
get temperature() {
return this.thermos;
}
set temperature(C) {
this.thermos = C;
}
}
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
The code above is my and the one below is the exercise.
Use the `class` keyword to create a `Thermostat` class. The `constructor` accepts a Fahrenheit temperature.
In the class, create a `getter` to obtain the temperature in Celsius and a `setter` to set the temperature in Celsius.
Remember that `C = 5/9 * (F - 32)` and `F = C * 9.0 / 5 + 32` , where `F` is the value of temperature in Fahrenheit, and `C` is the value of the same temperature in Celsius.
**Note:** When you implement this, you will track the temperature inside the class in one scale, either Fahrenheit or Celsius.