Skip to content

In section: "Classes" after subsection: "Getters/setters" in line 5 of code #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Annis-Monadjem opened this issue Aug 8, 2017 · 3 comments

Comments

@Annis-Monadjem
Copy link
Contributor

Annis-Monadjem commented Aug 8, 2017

In the constructor change this._name = name; into this.name = name; or as it is the code will not do what it is intended to do.

The final code should be:

class User {
  constructor(value) {
    // invokes the setter
    this.name = value;
  }

  get name() {
    return this._name;
  }

  set name(value) {
    if (value.length < 4) {
      alert("Name too short.");
      return;
    }
    this._name = value;
  }
}
@iliakan
Copy link
Member

iliakan commented Aug 9, 2017

Maybe suggest a PR? You can edit the article in github pretty easily! :)

@iliakan
Copy link
Member

iliakan commented Aug 9, 2017

And your contribution will be well-written in the history of the tutorial.

@Annis-Monadjem
Copy link
Contributor Author

I'm new to programming. If I'm understanding you correctly, you are saying that i should close this comment/issue and manually copy it into pull requests. I'll be opening a PR first time. Should i open an PR by forking this project or in any other way? please explain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants