I'm pretty sure this is right but it tells me it's wrong

So I wrote:

class Thermostat {
  constructor(fahrenheit){
    this.fahrenheit = fahrenheit; 
  }
  get temp() {
   return (5/9) * (this.fahrenheit - 32);  
}
  set temp(celsius){
    this.fahrenheit = (celsius * 9.0) / 5 + 32; 
  }
}

Look at the rest of the code in the editor:

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

What are the names of the getter and setter? That’s what you need to use in the Thermostat class.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.