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 trialIsolde Falke
56 PointsInvalid left-hand side. I really don't have a clue what I need to do with this task. Help would be appreciated :))
I really don't get what I need to do in this task. Please help me.
I don't know how I can add a value to the 'major' variable.
class Student {
constructor(gpa, credits, major){
this.gpa = gpa;
this.credits = credits;
}
stringGPA() {
return this.gpa.toString();
}
get level() {
const studentCredits =this.credits;
if (studentCredits > 90 ) {
return 'Senior';
} else if (studentCredits <= 90 && studentCredits >= 61) {
return 'Junior';
} else if (studentCredits <= 60 && studentCredits >= 31) {
return 'Sophomore';
} else {
return 'Freshman';
}
}
set major(major) {
this._major = major;
if (student.level = 'Senior' || student.level = 'Junior') {
major = student.major;
} else {
major = 'None';
}
}
}
var student = new Student(3.9, 60);
3 Answers
KRIS NIKOLAISEN
54,972 PointsThe error Bummer: Invalid left-hand side in assignment refers to this line
if (student.level = 'Senior' || student.level = 'Junior') {
You are using assignment operators instead of comparison operators
Isolde Falke
56 PointsOHH you're so right. Thanks so much ! Now I have another problem: Your setter method is returning the wrong value for the major property. :(
Darryl Mah
5,492 PointsUse the "this" keyword instead of student ;)
Darryl Mah
5,492 PointsDarryl Mah
5,492 PointsWhat Kris said. Change the “=“ to “==“ or “===“ and you should be good.