// Only change code below this line
// 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 (Linux; Android 10; SM-A207F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36.
Challenge: Use getters and setters to Control Access to an Object
Do you understand how methods work in a class? If you weren’t using getters/setters could you write a method that returns the temperature stored in the class? Could you write a method that updates the temperature stored in the class?
You need to understand the above first because setters/getters are basically just like any other method except they allow you to use some shortcuts when accessing them.