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 trialMoe Ghashim
11,109 PointsI'm getting "Your conditional statement is returning the wrong student level."
I'm getting "Your conditional statement is returning the wrong student level." error message and I couldn't figure out what I did wrong.
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level () {
if (this.credit >90) {
return 'Senior';
} else if (this.credit <=90 && this.credit >=61) {
return 'Junior';
} else if (this.credit <=60 && this.credit >=31) {
return 'Sophomore';
} else {
return 'Freshman';
}
}
}
const student = new Student(3.9);
2 Answers
Adam Beer
11,314 PointsYou are so close. Delete the second conditions inside the 2 else ifs. Fixed your "this.credit" to "this.credits", fixed your first else if stament conditional to this.credits > 60 and fixed your second else if stament conditional to this.credits > 30. Hope this help!
Antti Lylander
9,686 PointsYou are going great but credit
is not defined.
hint:
this.credits = credits;
Antti Lylander
9,686 PointsAntti Lylander
9,686 PointsHis conditionals do work, even though they are not the most concise. Also, please don't give straight answers to challenges. If it is not against any rules, it certainly does not help others to learn.
Adam Beer
11,314 PointsAdam Beer
11,314 PointsYes sir! I corrected my answer.