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 trialBlessing Phiri
20,261 Pointswhere am i doing this wrong?.
Challenge Task 1 of 2 Inside the Student class, create an empty getter method called level().
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level() {
const student = new Student(3.9)
const credits = student;
if (credits > 90) {
return 'Senior';
} else if (credits > 61 && credits <= 90) {
return 'Junior';
} else if (credits > 31 && credits <= 60) {
return 'Sophomore';
} else {
return 'Freshman';
}
}
}
var student = new Student(3.9, 60);
2 Answers
Steven Parker
231,184 PointsAre you sure you're just on task 1? That's quite a bit more than an "empty" method! But it should pass — try restarting your browser and do it again.
And this looks like the code for task 2, but I see two issues:
- it should work with the "credits" of the current object (this), don't create a new one
- make sure your range values match the requirements in the instructions
Habiballah Hezarehee
7,193 PointsIn the second task which you have already implemented, you need to refer the credits variable to current object which is being created. To do that you just need to add this. before credits anywhere you have used it. Good luck