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 trialDamian Szymanski
11,843 PointsStuck on this quiz
Hello!
I'm a bit stuck on this quiz. Here is my code:
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 < 91 && this.credits >= 60) {
return "junior";
} else if (this.credits <= 61 && this.credits >= 31) {
return "sophmore";
} else {
return "freshman";
}
const student = new Student(3.9);
Thank you! Damian.
1 Answer
Steven Parker
229,204 PointsIf you provide a link to the challenge I could check the specifics of the criteria; but even without seeing it, a few things stand out:
- the categories all probably need capitalized names
- "sophmore" should be spelled "Sophomore" (with 3 "o"s)
- this code returns "senior" for credits 90 and below, and "freshman" if over 90
- the order of the tests and values prevent the other values from ever being returned
Damian Szymanski
11,843 PointsDamian Szymanski
11,843 PointsThank you so much! I have figured it out!