ES6 - Usare getter e setter per controllare l'accesso a un oggetto

Tell us what’s happening:

Descrivi qui il tuo problema in dettaglio.

What is the problem in my code?

Your code so far

// Modifica il codice solo sotto questa riga
class Thermostat{
  constructor (fh){
    this._temperature = 5/9 * (fh - 32);
  get celsius(){
    return this._temperature;
  set celsius(nuovissima){
    this._temperature = nuovissima;
// Modifica il codice solo sopra questa riga
const thermos = new Thermostat(76); // Impostazione in scala Fahrenheit
let temp = thermos.temperature; // 24.44 in Celsius
thermos.temperature = 26;
temp = thermos.temperature; // 26 in Celsius

Your browser information:

Lo user agent è: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

ES6 - Usare getter e setter per controllare l’accesso a un oggetto

1 Like

Hello @baronemanu109 !

The Thermostat object you declare includes a reference to a property named:


The thermos instance references a property named:


If you remove the underscore ( _ ) from the object definition or, add it to your code below, your code will work.

Does this help?
Keep up the good progress!

Happy Coding! :slightly_smiling_face: