Use getters and setters, instantiation error

Tell us what’s happening:
I am trying to complete the lesson ’ ES6: Use getters and setters to Control Access to an Object’ but I am getting an error that reads:

Thermostat should be able to be instantiated.

Can someone explain to me what this means? I have looked through various forum posts on this same topic but no one has mentioned instantiation. My understanding is that it refers to being able to copy the class to create a new object but I can’t see what I would need to change to enable something like that. Any direction or information would be greatly appreciated, this is my first post so please just let me know if there is anything else I should add.

Your code so far


// Only change code below this line
class Thermostat {
constructor(F) {
  this._F = F;
}
get temperature() {
  return (5/9) * (this.F - 32);
}
set temperature(C) {
  this.F = (C * 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

Your browser information:

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

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

Link to the challenge:

It’s not necessarily the best error message. “Instantiate an object” means to create an instance of an object. The following line of code does that:

const thermos = new Thermostat(76);

This actually works just fine. What is not working correctly in your case is the next line:

let temp = thermos.temperature;

The getter is not returning the correct value. Add a console.log(temp) after that line and you’ll see the value it is returning.

I added the console.log(temp) line like you said and saw that temp was returning NaN. At first I thought it was a math error but when I was taking a closer look at the equation I realized I didn’t have the correct variable, I was using ‘this.F’ instead of ‘this._F’ which I had defined earlier. I updated the variable in the getter and the setter then ran the code without issue. Thanks for the help!