Typo on Getter/Setter?

First time posting here, I hope this is the right way to do it.

I just did “Use getters and setters to Control Access to an Object” in the JavaScript Algorithms and Data Structures: ES6 module, and it asks us to set the temp in Celsius, but after looking at the answer, shouldn’t this be asking us to set the temp in Fahrenheit (since we are giving it the temp in Celsius and it sets the Fahrenheit temp)? I would have posted on that challenge’s answer but I don’t see a way to comment on it.

This is slightly confusing :slight_smile: There are two ways to set the temperature. The first is in the constructor, which only takes the temp in F. This is used when you initially create the object:

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

The second is through the getter, which only takes the temp in C. This is used when you set it equal to a value:

thermos.temperature = 26;

And since the setter can only accept a value in C, you can’t say to set the value in F, because that is against the rules for this challenge.

Internally, you can keep track of temp in either F or C, it doesn’t matter for this challenge, the choice is yours. So the instructions can’t know which one you are using for the internal temp, they only tell you which values each method must accept.

Right, yes, I understand how to complete the challenge, I’m just saying that the wording of the challenge instructions is confusing because it says “In the class, create a getter to obtain the temperature in Celsius and a setter to set the temperature in Celsius” but what it really wants you to do is “set the temperature in Fahrenheit.” So I spent a long time trying to figure out what I was supposed to do because I thought I was being told to “set the temperature to a C value,” when I would have understood that it wanted me to set the temp in F if it had said to set the temp in F.

I understand that you can only use C as an input, but at the end of the day this part of the question is asking you to convert C into F so that you end up with an F value. I’m just suggesting that it might be easier on learners if it were worded as “create a setter to set the new Fahrenheit temp when a Celsius value is inputted.” It’s not a big deal, I was just making a suggestion to make sure learners don’t think they’re being told to do something else.

What I’m saying is that it does not really want you to set the temp in F because it doesn’t care whether you keep the internal (real) temp in F or C. No where in the instructions does it say that you must keep the internal temp in F. It is up to you to decide whether you want to store the internal temp in F or C. So it would be a mistake to say to “set the temp in F” because you aren’t doing that with the setter and there is no requirement to keep the internal temp in F.

No, it’s not. It doesn’t care if you end up with an F value. In the constructor you can convert the F value passed in to the constructor to C immediately and never have to deal with conversions again. In fact, that would be my recommended approach. See the note:

Note: When you implement this, you will track the temperature inside the class in one scale, either Fahrenheit or Celsius.”