Why the tests keep accusing the lack of headers and setters?

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**

// Only change code below this line
class Thermostat{
  this.fahrenheit = newFahrenheit;
  this.temperature = 5/9 * (newFahrenheit - 32);
// getter
get celsiusThemp() {
  return this.temperature;
// setter
set celsiusThemp(newCelsius) {
  this.temperature = newCelsius;
  this.fahrenheit = newCelsius * 9.0 / 5 + 32;
// Only change code above this line

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
thermos.celsiusThemp = 25; // 26 in Celsius
temp = thermos.celsiusThemp;
  **Your browser information:**

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

Challenge: Use getters and setters to Control Access to an Object

Link to the challenge:

Your getter and setter are supposed to be called “temperature”. The class property should be called something else. You don’t need to store the temp twice. Outside the class, we don’t care how it is stored. All we care is that the constructor takes F and the getter and setter deal with C. The internal storage is hidden. Store it as C or F. Just make sure that it doesn’t have the same name as your getter and setter. A common standard is to precede it with an underscore (_) to tell people that it is private. Many languages allow you to enforce private properties. JS didn’t when this was written but does now.

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