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 trial

JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

Moe Ghashim
Moe Ghashim
11,109 Points

I'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.

creating_getters.js
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
Adam Beer
11,314 Points

You 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
Antti Lylander
9,686 Points

His 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
Adam Beer
11,314 Points

Yes sir! I corrected my answer.

Antti Lylander
Antti Lylander
9,686 Points

You are going great but credit is not defined.

hint:

this.credits = credits;