exondus
November 15, 2019, 12:46am
1
Hi, please help me with the Getter and Setters. My code results in the following message: “Thermostat should be able to be instantiated.”
Here is my code:
class Thermostat {
constructor(fahrenheit) {
this._fahrenheit = fahrenheit;
}
get temperature() {
return (5 / 9) * (this.fahrenheit - 32.0);
}
set temperature(celsius) {
this._fahrenheit = (celsius * 9.0) / 5.0 + 32;
}
}
Thank you in advance.
get temperature() {
return (5 / 9) * (this.fahrenheit - 32.0);
}
this.fahrenheit does not exist
exondus
November 15, 2019, 11:21am
3
Oooops! Thank you so much!!!
n8trufe
November 24, 2020, 5:27am
4
Hi together
Actually I have the same problem as exondus, but I think, there is nu typo.
Here is my code:
class Thermostat {
constructor(fahrenheit) {
this._fahrenheit = fahrenheit;
}
get getCelsius() {
return (5/9 * (this._fahrenheit - 32));
}
set setFahrenheit(celsius) {
this._fahrenheit = (celsius * 9.0 / 5 + 32);
}
}
And I always get this result:
Thermostat should be able to be instantiated.
A getter should be defined.
A setter should be defined.
Where is my Problem?
Thanks in advance.
codely
November 24, 2020, 7:08am
5
Hey @n8trufe !
The post is inactive for 1 year. I suggest you create a topic
1 Like
ILM
November 24, 2020, 8:09am
6
If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
Thank you.
1 Like