I Hope You Will Be Able To Figure It Out!

I Believe that I am doing this right!
Please help me figure why this is not working???

// Only change code below this line


class Thermostat{
constructor(temperature){
  this._temperature = temperature;
}
get celctemp(){
  return 5/9 * (this._temperature - 32);
}
set celctemp(newTemp){
  this._temperature = newTemp * 9.0 / 5 + 32;
}
}


// Only change code above this line

const thermos = new Thermostat(76); // Setting in Fahrenheit scale
console.log(thermos)
let temp = thermos.celctemp; // 24.44 in Celsius
console.log(thermos.celctemp)
thermos.celctemp = 26;
temp = thermos.celctemp; // 26 in Celsius
console.log(temp)

Please make sure to send link to the lesson, i remember it( and how much i hated it) but i just cant seem to find it :laughing:
It will help others help you

What have you noticed isn’t working and what do you think the problem is, what have you tried?

The tests tell me that:

  1. I need to “set the correct temperature when instantiating” (I am definitely doing so!)
  2. A getter should be defined. (I am definitely doing so!)
  3. A setter should be defined. (I am definitely doing so!)
    Thanks so much for any help you can give me!

It looks like you changed some code outside of the “only change this code” comments.

Here’s the original starter code:

// Only change code below this line

// 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

Notice, they expect to be able to interact with the Thermostat object via a temperature property.

I replaced it with the original but it still won’t work

Does your Thermostat class have a getter and setter for temperature?

yes. The code I posted at the beginning is the code I’m using

I see celctemp, not temperature.

THANKS!!!

Why don’t they say that explicitly??!!

It shouldn’t matter for the syntax!

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

Good job solving it! I agree that it’s confusing that it’s not mentioned in the instructions, but the tests and the above code explicitly refer to temperature. Next time don’t touch the code you’re not supposed to touch!

Thanks.
I learned my lesson!
:muscle:

class Thermostat{
constructor(temperature){
this._temperature = temperature;
}
get celctemp(){
return 5/9 * (this._temperature - 32);
}
set celctemp(newTemp){
this._temperature = newTemp * 9.0 / 5 + 32;
}
}

// Only change code above this line

const thermos = new Thermostat(76); // Setting in Fahrenheit scale
console.log(thermos)
let temp = thermos.celctemp; // 24.44 in Celsius
console.log(thermos.celctemp)
thermos.celctemp = 26;
temp = thermos.celctemp; // 26 in Celsius
console.log(temp)