Answers for "javascript getterand setter"

0

javascript getterand setter

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;
  }
}
Posted by: Guest on April-20-2021

Browse Popular Code Answers by Language