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 trialThomas Tilton-Heylin
12,098 Pointscreate an empty setter method called "major()"
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 (level() = 'Senior' || 'Junior') {
this._major = major;
} else {
this._major = 'none';
}
}
}
var student = new Student(3.9, 60);
Liam Clarke
19,938 PointsHi Thomas
I have changed your title from "k" to the name of the challenge your referring to
Giving a descriptive title will give you more chance of finding a solution.
2 Answers
Steven Parker
231,269 PointsI did spot some issues:
if (level() = 'Senior' || 'Junior') {
- reference to a "getter" property should be done like a normal one, use "this.level" instead of "level()"
- only complete conditional tests can be combined with logic operators
- one "=" is an assignment operator, use two ("==") for comparisons
For any future questions, please be sure to describe your issue in complete sentences, and give your question a descriptive title.
Welcome Julius
9,076 Pointssteven parker just give the answer the two tasks are complicated
Steven Parker
231,269 PointsThis is a rather old question. If you have an issue not addressed by this one, you might consider posting a new questions of your own.
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI know "jk" is commonly used as a abbreviation for "just kidding". But I don't get the joke?