Tell us what’s happening:
Trying to pass the learn Es6: Use getters and setters to control access to an object.
Telling i still need to :1. Define a ggetter,
2. Define a setter
3. The Thermostat should be able to be instantiated
my original attempt was extremely simmilar to the one offered in the hint solution, now it is almost an exct copy and it still will not work. The use of getters and setters i have seen online shows the getter being defined it a getName form but this seems to take me farther away from the solution
Your code so far
// Only change code below this line
/////
class Thermostat {
constructor(fTemp){
this._fTemp=fTemp
int fTemp
}
// getter
public void get temp(){
return((5/9)*(this._fTemp - 32))
}
// setter
public void set temp(celsius) {
this._fTemp=((celsius * 9)/5+32)
}
}
const l=new Thermostat
// Learning Getters and setters
// 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_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
.
Challenge: Use getters and setters to Control Access to an Object
Link to the challenge: