Use getters & setters to control access to an object

Use getters & setters to control access to an object
0

#1

Hi
can anyone help with this code, i’ve tried various versions but i’m not getting any response from test output.
my code:

function makeClass() {
  "use strict";
  /* Alter code below this line */
class Thermostat {
  constructor(temperature) {
    this._temperature = temperature;
  } 
  get Celsius(){
    return this._temperature;
  }
  set Celsius(c = 5/9 * (F - 32), F = C * 9.0 / 5 + 32){
    this._temperature = (c = 5/9 * (F - 32), F = C * 9.0/ 5 +32);
  }
}
  /* Alter code above this line */
  return Thermostat;
}

Thanks for any response


#2

The above line is a problem. You just need to put parameter names. This is just a function like all functions you have been using all along. Where have you seen a formula inside the ( ) where parameters go?

All calculations should take place between the { }.


#3

Thanks Randell,
Got it.