Message to the staff of freecodecamp about setters and getters challenge

Tell us what’s happening:
The challenge doesn’t pass, only because of the name of the getter and setter, for the challenge to pass the name of the “property” should be set to “Temperature”.

I don’t know if it is a bug in the “code tester”, or something else…
I’d suggest to atleast put in the description of the challenge that the name of the getter and setter must be set to “Temperature”

Thermostat should be able to be instantiated.
A getter should be defined.//but doesn't say that the name should be Temperature
A setter should  be defined.//but doesn't say that the name should be Temperature

Your code so far


// Only change code below this line
class Thermostat {
constructor(temp) {
    this.temp = temp;
}
get temperaturek() {
    return (this.temp-32)*5/9;
}
set temperaturek(celsi) {
    this.temp = (celsi*9.0)/5+32;
}
}
// Only change code above this line


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

Link to the challenge:

I think it’s rather self explanatory that the name should be set to temperature by looking at the code in the challenge:

// Only change code below this line

// Only change code above this line

const thermos = new Thermostat(76); // Setting in Fahrenheit scale

// temperature is used here
let temp = thermos.temperature; // 24.44 in Celsius

thermos.temperature = 26;
// and here
temp = thermos.temperature; // 26 in Celsius
2 Likes

Maybe for a pro not for a noob…

By no means I’m not a pro :smiley:

I just pointed that the information is actually there, you haven’t noticed it but you’ll next time in a similar situation :slight_smile:

1 Like

Hi @bedward,

Do you understand what the code below the only change code above/below this line markers is doing?

If you’re not sure you should try to reason it out using the example of the Book class given in the lesson. Notice how the setter and getter for the writer is defined and used. That will hopefully clue you into the reasoning you can do about the code provided in the challenge and what you should be using for the name of the getter and setter.

Hello, there.

Thank you, for taking the time to mention improvements for freeCodeCamp. The others are correct, in mentioning the seed code (code given at the start) is plenty to infer from, and most campers do.

Unfortunately, I do not know the author’s original intentions behind this challenge, but I assume the mention of such specifics was deliberately left out, because of this section in the instructions:

In other words, you are abstracting implementation details from the user.

In other words, the code you start off with is the user’s desired use, and you must create the functionality to match. This is very common in a professional setting.

Hope this clarifies.