Help with Use getters and setters to Control Access to an Object

Tell us what’s happening:
Can somebody tell me why my code isnt running?

Your code so far

// Only change code below this line
class Thermostat {
constructor(farenheit) {
  this.farenheit = farenheit
get tempreture() {
  return  (5 / 9) * (this.farenheit * 32)
set temperature(celcius) {
  this.farenheit = (celcius * 9.0) / 5 + 32


// 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 9; LM-X420) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Mobile Safari/537.36.

Challenge: Use getters and setters to Control Access to an Object

Link to the challenge:

Your getter is misspelled.

Okay @snowmonkey , YES, but also:

  • The formula in the get method is wrong (you are multiplying farenheit by 32, instead of SUBTRACTING 32)
  • To avoid unexpected behavior, you should be ending your return and assign statements with a semicolon: e.g., this.farenheit = farenheit;

Feel free to reply if you can’t get it working with these tips :slight_smile:

1 Like

You’re right about the formula behind wrong. But with the function name misspelled, the formula never fires anyway.

And semicolons are a suggested guideline, but in this case there will be no unexpected effects. Given that the brackets are closing immediately following, there are no multi-line expressions.

1 Like

Okay regarding semicolons, yes, and I don’t want to get into some kind of pedantic argument, but for someone learning programming they should absolutely be terminating expressions with a semicolon, and anyone doing this in a production environment should also be ending expressions with a semicolon unless they have a really good reason not to. Just trying to remind them since I think it’s in their best interest to practice ending expressions with semicolons basically every time.


You need to be submitting the Live App link. This is the link you copy from the Picture-in-Picture browser, on the top right hand side of the REPL editor. There is an example of the link format, in the placeholder of the solution box.

The tests do not work with links to code files. random talk chat random It has to be a publicly visible, live app. This also means the app has to be running in the background.