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 trialEmil Storberg
3,533 PointsI cant find the { causing problem
It says there's a { where it shouldn't be, but I can't find it
class Student {
constructor(gpa, credits){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level() {
if (this.credits > 90) {
return "Senior"
} elif (this.credits >= 61) {
return "Junior"
} elif (this.credits >= 31) {
return "Sophomore"
} elif (this.credits < 30) {
return "Freshman"
}
}
}
const student = new Student(3.9);
1 Answer
Steven Parker
231,269 PointsThe challenge is just confused and complaining about the wrong thing. The main issue is that "elif" is not a keyword in JavaScript (it is in some other languages). Here, you probably want "else if".
Also, when doing a conditional chain, it's common to make the last case a plain "else" instead of another "else if" to be sure all cases get handled. For example, in this particular code, what would be returned if the credits are exactly 30?