Use getters and setters to Control Access to an Object bug?

Use getters and setters to Control Access to an Object bug?
0.0 0

#1

Tell us what’s happening:
I created the constructor, getter and setter but didn’t do any math with any of them so they always return farenheight. I tested the code to see if it would pass and it did… Is this a bug? I had to convert from f to c with the weather app and was going to copy and paste something like that in and update it to es6 but it looks like I didn’t need to.

Your code so far


function makeClass() {
  "use strict";
  /* Alter code below this line */
class Thermostat{
  constructor(Fahrenheit){
    this.temperature=temp
  }
  //getter
  get temp(){
    return this.temperature
  }
  //setter 
  set temp(tempc){
    return this.temperature
  }
}
  /* 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; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 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


#2

Definitely appears to be a bug.