Tell us what’s happening:
I wonder whether this solution is really correct or not.
It passes the test but I want to know if it does what it is supposed to.
I know there is an issue with this particular challenge, that’s why I asked you guys to make sure the solution is correct. Thanks in advance.
Your code so far
function makeClass() {
"use strict";
/* Alter code below this line */
class Thermostat{
constructor(fh){
this._tmp=fh;
}
//getter
get cels(){
return 5/9*(this._tmp-32);
}
//setter
set cels(updTemp){
this._tmp=updTemp;
}
}
/* Alter code above this line */
return Thermostat;
}
const Thermostat = makeClass();
const thermos = new Thermostat(76); // setting in Fahrenheit scale
let temp = thermos.temperature; // 24.44 in C
thermos.temperature = 26;
temp = thermos.temperature; // 26 in C
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-getters-and-setters-to-control-access-to-an-object