Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Object-Oriented JavaScript Getters and Setters Creating Setter Methods

Hey everyone, I'm sorry if I am being difficult. But I would really like some to explain this to me.

Hey everyone, I just wanted to say thank you for everything that you guys do. I have learnt a lot from this tech degree program but one thing I would like you guys to improve on in the future is I really think you guys need to explain how these elements of programming are going to be useful in this field as there are a lot of elements of programming within this program where I just don't understand why we need to learn it and how it would be used in a job setting.

And I think this is important for us to understand why we are learning these features otherwise we question the point as to why we have to learn these elements of programming and how they will helps us get a job and do the job.

So if in the future you guys could maybe show how it could be used in a workplace or developer role that would be really helpful for some students I feel. Sorry to sound like a Karen but I hope this feedback is ok.

On another hand please could you help me understand why I am not getting this right. I have no idea despite the video how to solve this XD

creating_setters.js
class Student {
    constructor(gpa, credits){
        this.gpa = gpa;
        this.credits = credits;
    }

    stringGPA() {
        return this.gpa.toString();
    }

    get level() {
        if (this.credits > 90 ) {
            return 'Senior';
        } else if (this.credits > 60) {
            return 'Junior';
        } else if (this.credits > 30) {
            return 'Sophomore';
        } else {
            return 'Freshman';
        }
    }

    set major(major) {
      this._major = major;
      if (this.level == 'Senior' || this.level =='Junior') {
        this._major = major
    }
}

var student = new Student(3.9, 60);