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 trialgiorgio gristina
Front End Web Development Techdegree Graduate 13,839 Pointshi guys i m trying to do this exercise and i dont understand why my solution is not correct.
what i did:
- created a setter giving a parameter of major; -created a backing property _major to store the value;
- and created a conditional using the getter level to know who is senior or junior... ;
thanks in advance for your help if u have any feedback about how i wrote the code and my question. i m happy to hear them
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;
} else {
this._major = 'None';
}
}
}
var student = new Student(3.9, 60);
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsYour code is all correct except for one thing. You seem to have a set of single quotation marks before the variable name major
. This is the third line inside your setter block. this.major = ''major
. Once you delete those errant quote marks, the code will pass.
Nice work! :)