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 trialJason Berry
5,180 PointsI'm not understand how to writer the setter method.
It asks for the setter method but when I try to write the empty method I continue to receive unexpected identifier.
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()
var student = new Student(3.9, 60);
2 Answers
Antti Lylander
9,686 Points- you must set it inside the Student class
- do not capitalize the first letter in major
- you are missing curly braces
Once you fix these issues, I'm sure you'll make it. If not, watch the videos again.
Steven Parker
231,275 PointsI can see four issues:
- the setter must be defined inside the class
- you wrote "Major" but the instructions ask for the name to be "major" (lower case)
- a setter must have one parameter
- an "empty" method would still have a pair of braces