Use getters and setters to Control Access to an Object new

Tell us what’s happening:

Your code so far

This passes the test but i was able to get it pass without the getter and setter, can you please see if this is correct.


function makeClass() {
  "use strict";
  /* Alter code below this line */
    class Thermostat{
     
      constructor(Fahrenheit){
        this.celsius = 5/9 * (Fahrenheit - 32);
      }

      get writer(){
        return this.celsius;
      }

      set writer(Updatedcelcius){
         return this.celsius = Updatedcelcius;
      }

    }
  /* Alter code above this line */
  return Thermostat;
}
const Thermostat = makeClass();
const thermos = new Thermostat(76); // setting in Fahrenheit scale
let temp = thermos.temperature; // 24.44 in C
thermos.temperature = 26;
temp = thermos.temperature; // 26 in C

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object

The names you picked for your setter and getter are not matching the requirements. Review the code that invokes them so you can figure out the correct names.

Same with me,

There seems to be a bug in the code and, I’m able to pass the challenge without any setters or even with incomplete code.
I did this:

class Thermostat {
   constructor(tempInFahrenheit){
     this.tempInFahrenheit = tempInFahrenheit;
   }
    get Celcius(){
       this.Celcius = 5/9 * (tempInFahrenheit - 32);
   }
    set Celcius(celciusIn){
       this.tempInFahrenheit = celciusIn * 9.0 / 5 + 32;
   } 
}

Not entirely sure if its the right answer dough…

Let me know some feedback!