Tell us what’s happening:
I’m not sure how to do math up against a property, I made some Pseudo-pseudo code to try and explain what I am attempting if someone could let me know if I’m going in the right direction
Your code so far
// Only change code below this line
class Thermostat {
constructor(fahrenheit) {
this._temp = fahrenheit;
get celcius() {
return this._(5/9*(temp - 32));
}
set temp (updatedTemp) {
this._temp(5/9*(temp - 32)) = celcius;
}
}
}
// 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Challenge: ES6 - Use getters and setters to Control Access to an Object
Almost there. Take a look at the lines at the end, with example how the class is used.
Specifically:
let temp = thermos.temperature; // 24.44 in Celsius
thermos.temperature = 26;
There’s an attempt to access (get) temperature property and then to set it. However class from your post do not have the temperature property, nor the getter/setter for it. Your current version would work, if tests would expect the getter/setter for temp.