Use getters and setters to Control Access to an Object, passing without getter or setter?

Tell us what’s happening:
The code that I wrote below passed the challenge, but I am not sure why. I checked it before finishing just to make sure I satisfied the constructor, but never put in a getter or setter. It passed just after putting in the constructor.

Thanks!

Your code so far


function makeClass() {
  "use strict";
  /* Alter code below this line */
class Thermostat{
  constructor(temp){
    this._temp = temp;
  } 
}
  /* 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 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 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

There’s clearly a problem in this challenge; it doesn’t assess whether getters and setters have been set.

You can see all the tests required on the bottom left of the window.

Yea, the tests don’t actually test anything, there have been multiple issues submitted to get it fixed but for now it is what it is, the tests will not actually test the solution.

@clevious @DanCouper
Ah, thanks for the response guys. I thought that’s what was going on. Glad to hear it’s not just me.

1 Like

Good Luck & Happy Coding.

Hello - I just found the same thing - it didn’t matter if the setter and getter were properly named, there were no errors when the results didn’t match but it ended up passing the tests, perhaps just checking that those few necessary conditions are correct. Definitely some problems with it! Or at least with the description of the temperature conversion formulas, it seems that a little more was expected.

Same here. I’m glad I looked on the forum, because I was just to the point of getting it, but then it confused me again lol.