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 trialJonathan Ambriz
Courses Plus Student 3,902 PointsSenior, Junior, Sophomore, Freshman get question.
I'm not sure what my code is doing wrong. It says: Bummer: output is not defined.
It should be a string, right?
Any help would be appreciated!
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
get level () {
let grade = "";
if (this.credits > 90) grade += "Senior";
if (this.credits <= 90 && this.credits >= 61 ) grade += "Junior";
if (this.credits <= 60 && this.credits >= 31 ) grade += "Sophomore";
if (this.credits <= 30) output += "Freshman";
return grade;
}
stringGPA() {
return this.gpa.toString();
}
}
const student = new Student(3.9);
1 Answer
Brandon White
Full Stack JavaScript Techdegree Graduate 34,662 PointsHi Jonathan,
In the part of your code where you’re trying to set the grade to “Freshmen”, you’re not using the grade variable. You’re trying to use a variable you’ve named output, but output has not been defined before that point.