Tell us what’s happening:
Describe your issue in detail here.
When I run the tests, it tells me there is no getter or setter defined. Your code so far
// Only change code below this line
class Thermostat {
constructor(fahren) {
this._fahren = fahren;
}
//getter
get temp() {
return (this._fahren-32)*(5/9);
}
//setter
set temp(cels) {
this._fahren = (cels*9) / (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/92.0.4515.159 Safari/537.36
Challenge: Use getters and setters to Control Access to an Object
When instantiated with a Fahrenheit value, Thermostat should set the correct temperature .
They want the property to be called “temperature”, not “temp” or “fahren”. Typically the private member has the same name as the getter/setter, just prepended with an underscore.
Thanks, yes, I did continue searching and found the hint that the name of the getter/setter needs to match the other code.
And yeah math isn’t my strong suit.
Yeah, for web dev, you don’t have to be a math genius, but having some basic math skills is good. I always say that most 12 year-olds know enough math for most of what we do. I think being able to invert a formula like:
C = (F - 32) * (5 / 9)
should be a good goal. I think very, very basic algebraic manipulation should be a good thing to have. If that is a struggle for you, I might look for some tutorial videos on basic algebra and formula manipulation. (I’m not even sure of the name here.) You don’t need a lot of advanced stuff (for most web dev jobs) but some basics will make your life easier.