There should have been a lesson to creating functions inside a class before we compare a function inside a class and getter-setter functions

Same challenge. You only get one topic per challenge. Please don’t make duplicates… Thanks.

It doesn’t matter as long as you pick one. Valid solutions can be written with the temp stored in either F or C. There are two different solution approaches that are both valid.

The entire point is that getters and setters do not depend upon internal data representation choices.

From my understanding your code is doing what it should, so I tried to rewrite the requirements using different words…

1 Like

Yeah, sometimes these challenges don’t make a lot of practical sense. They can seem odd and have a lot of “wait! why?” moments.

But:

  1. It is hard to come up with simple teaching examples with enough variety and that “make sense” in the real world.
  2. Even in the “real world” you will get jobs that don’t seem to make sense, where you are just given a list of requirements and you don’t completely get the end product, or you do and you don’t think it is the right approach. It happens.

-While creating an instance of the class, setting the temperature to whatever doesn’t matter Celsius or Fahrenheit.

No, the instructions are “The constructor accepts a Fahrenheit temperature.”

So, the constructor will receive in F. Where it doesn’t matter is that you can store it however you want, F or C (or K or R for that matter). You chose to store it as the constructor received it, in F. That is fine, I could make an argument that it would be better to store it as C since you will need to access it more that way, but it works either way.

With get function, convert the value to Celsius, even if it is already in Celsius, and return this value.

You stored it in F so it needs to be converted. If you had converted and stored in C in the constructor, then you wouldn’t need to convert.

With the set function, convert the value that we are getting from arguments to Fahrenheit and set it. Doesn’t matter if its already in Fahrenheit.

No, it does matter. The instructions are: “In the class, create a getter to obtain the temperature in Celsius and a setter to set the temperature in Celsius.”


You could have written it differently, where everything is C (or whatever). You could have written it to allow either F or C (which would have been more complicated, but doable.

But as the problem is given to you, the constructor accepts F and the getter and setter deal in C. Does that make sense in the “real world”? Maybe not. It’s a little odd. Is it the type of “strange requirements” you may encounter on the job? Yup.

If I were designing this module from scratch, it certainly wouldn’t work this way. But I didn’t design it. Sometimes we have to understand and build to other people’s specifications.

As to the description, I think it’s decent. Trust me, on the job, I’ve gotten much, much worse specs, with contradictions and gaping holes.

2 Likes

Im just trying to help report problems with the challenges what others may find difficult to understand. I can just move past this as I understood the lesson but I am making effort to report problems.
I think its not a bad thing to acknowledge someone’s effort.
Also combining posts for different thing and saying ~one post per challange~ is really rude. Is there a storage limitation for a simple text post?
Anyway ill not be making any new posts for reporting any issuse. Thanks.

1 Like

I didn’t write the rule, I just enforce it.

You made two posts about the clarity of the instructions on this one challenge. I combined them. It wasn’t an admonishment or anything. I’m just being consistent with the rules. You’re still welcome to create topics about other challenges in the future.

1 Like

I think it’s a reasonable rule. Some people end up creating a lot of simultaneous threads on the same challenge, creating confusion and clogging up the board. In theory, these lessons should be incremental and there should only be one or two new concepts so in the vast majority of cases, there shouldn’t be a lot of different questions, certainly few enough to be handled in one post.

I agree with what Jeremy did. And no one is getting down on you here, this is a friendly bunch. You just did something that we don’t like here so it got corrected. It’s no big deal.

1 Like

The previous post was that the theory of the lesson has topics that have not been mentioned and taught yet.
And the other post was that the challenge’s language is not clear.
I don’t know how I can discuss both these things in one post.

OK, so we disagree on the semantics here. But now you know what the policy is. Maybe we can just not worry about debating moot points and move on?

1 Like

And if you have a suggestion about how to improve a challenge, you can bring it up in the Contributors subforum.

2 Likes

Then there should be a different tag for reporting problems with challenges separate from those posts asking for help. If there is something like this, let me know. I’m not taking offence from this don’t worry.

I would say that until we understand the problem and the solution, we probably aren’t in a position to make criticisms with the challenge. What I would have expected was a thread on “explain how this works”. Once that was finished, after some reflection and understanding, perhaps then we might have a suggestion that goes into the Contributors subforum.

I don’t understand trying to make suggestions before we understand the challenge. Until we understand it, it all tends to fall under the “I don’t understand this” banner.

Those are my thoughts anyway.

1 Like

I never said I didn’t understood the lesson about getters and setters as its easy enough. My only frustration was that I spent like an hour to understand the ENGLISH of the challenge and as my solution code doesn’t match what the challenge description wants me to do, I can say with confident that the challenge description is not clear or entirely wrong.
I am thankful for this free resource and I can understand free resources comes with their own setbacks.
I am sorry if I said anything wrong but this is what I really feel like.
I have researched about the curriculum of ES6 and many users have acknowledged that its arrangement not user friendly as confirmed by @lasjorg in my previous post:

I am still wasting my time providing clarification and feel like I am being said ~You are wrong~

1 Like

Your solution code does match what the challenge is requesting though… It passes the tests. It meets the requirements.

Re: methods

There does seem to be an odd gap between this and the previous challenge. Not sure why the previous challenge doesn’t just show the syntax for a method.

It shows the class syntax and the constructor but never shows what a method looks like. Then it just jumps to getters and setters in the next challenge.

Code
class SpaceShuttle {
  constructor(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }
  destination() {
    return 'Space shuttle destination ' + this.targetPlanet;
  }
}

const zeus = new SpaceShuttle('Jupiter');

console.log(zeus.targetPlanet); // Jupiter
console.log(zeus.destination()); // Space shuttle destination Jupiter

Re: this challenge

A lot of people get confused by this challenge and the minutia of it seems to overshadow what is being taught. I think a much simpler example of using getters and setters, which might even tie in the previous challenge would be better.

Code
class SpaceShuttle {
  constructor(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }
  get destination() {
    return 'Space shuttle destination ' + this.targetPlanet;
  }
  set destination(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }
}

const zeus = new SpaceShuttle('Jupiter');
console.log(zeus.destination); // Space shuttle destination Jupiter

zeus.destination = 'Mars';
console.log(zeus.destination); // Space shuttle destination Mars

It might not show the power of getters and setters but at least it’s more clear what is going on. You can add some logic but then it gets a bit convoluted again.

Code
class SpaceShuttle {
  validTargets = [
    'Mercury',
    'Venus',
    'Mars',
    'Jupiter',
    'Saturn',
    'Uranus',
    'Neptune',
  ];

  constructor(targetPlanet) {
    this.targetPlanet = targetPlanet;
  }

  get destination() {
    return 'Space shuttle destination: ' + this.targetPlanet;
  }

  set destination(targetPlanet) {
    if (this.validTargets.includes(targetPlanet)) {
      this.targetPlanet = targetPlanet;
    } else {
      this.targetPlanet = `Error invalid destination ${targetPlanet}`;
    }
  }
}

const zeus = new SpaceShuttle('Jupiter');
console.log(zeus.destination); // Space shuttle destination Jupiter

zeus.destination = 'Mars';
console.log(zeus.destination); // Space shuttle destination Mars

zeus.destination = 'Pluto';
console.log(zeus.destination); // Space shuttle destination: Error invalid destination Pluto

If you want to report issues with the challenges then using the issues on GitHub is always an option.

1 Like

I know its probably not in the cards, but I’ve felt for a while now like these ES6 lessons should be separated and stuck in the sections where they best fit rather than being segregated into a separate chuck of the curriculum since ES6 is basically mainstream JavaScript now.

1 Like

Thanks you for replying! But I am moving past this and just completing the ES6 section as I think the OOP section is more useful and provides more clarification about classes,
Issues i have found with the ES6 section is
-Use of ~this~ keyword without mentioning mentioning it before
-Not teaching how to create a function before getters and setters
-Not teaching the differences between an Object Literal and and an Object Instance created by a n Object Constructor.

I hope this is helpful for concerned parties. The Moderators can close this thread if they want.

1 Like

I think most efforts to “fix” the aging curriculum have been put on the backburner in favor of focusing on getting the new version of the curriculum out sooner. Which makes total sense.

2 Likes

Like any “product” with user interaction, feedback should be valued and listened to.

Teachers often forget what it is like being a student, which can lead to a lack of empathy. It can be hard to objectively teach something you already know without your own knowledge getting in the way. Teaching is harder than it looks. Student feedback should be used to make corrections as and if needed (not that the student is always right mind you).

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.