Can anyone explain what the code from the solution is doing step-by-step? Here’s the official solution:
Next time you want to showcase a code, use the ` backtick so it is easier for everyone to read.
See this post to find the backtick on your keyboard.
The “preformatted text” tool in the editor (</>) will also add backticks around text.
What part is confusing? The general idea is that you are not allowing direct access to the variables inside the object. Instead you are providing some input preprocessing, output conversion, etc. Often you use setters for input validation.
So, is it the reason why, when you make a console.log request, “temperature” does not appear in the object, but just “fahrenheit” and its corresponding value?
That is what confuses me.
It is as if, what is made with get/set (i.e. “temperature”) does not belong to the object created with the constructor.
But still, you can access it because it is like… it is here… somewhere on the internet.