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

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~

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.

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