✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
class Temperature {#celsius;
constructor(c) { this.#celsius = c; }
get fahrenheit() {
return this.#celsius \* 9/5 + 32;
}
set fahrenheit(f) {
this.#celsius = (f - 32) \* 5/9;
}
}
const t = new Temperature(0);
console.log(t.fahrenheit);