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 trialChris Walker
5,004 PointsI think your editor is looking for specific syntax despite what I have returning a valid response.
Why's my syntax considered incorrect?
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level() {
const credits = this.credits;
if (credits > 90){
return 'Senior';
} else if (credits > 60){
return 'Junior';
} else if (credits > 30){
return 'Sophmore';
} else {
return 'Freshman';
}
}
}
const student = new Student(3.9,60);
1 Answer
Dave StSomeWhere
19,870 PointsYou are not returning a valid response since you have a spelling error on one of your return values. Your logic is correct (not sure why you defined a variable for credit as opposed to just using this.credits).
Chris Walker
5,004 PointsChris Walker
5,004 PointsHa. Thanks. It was just that spelling error. As for the 'this.credits', I didn't care for the repeated this. over and over. Wanted to clean up the syntax.