Reference error at ES6: Use getters and setters to Control Access to an Object

Tell us what’s happening:
i solved the challenge and it keeps telling ther’a a reference error :thermostat is not defined

how can this happen and how i can solve it ?

also it says these requirements are not fulfilled

Thermostat should be a class with a defined constructor method.
A getter should be defined.
A setter should be defined.

Your code so far

// Only change code below this line

class thermostat {
constructor(fahrenheit) {
  this._fahrenheit = fahrenheit;
get temperature() {
  return 5/9 *(this._fahrenheit-32);
set temperature(celsius) {
  this._fahrenheit=celsius ;
// 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:

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

Link to the challenge:

You just have to capitalize thermostat.

class Thermostat {


thank you so much !!

the tests are not testing it, it seems, but you can’t store a celsius value as fahrenheit without conversion - you would need to convert the celsius value to fahrenheit

1 Like