JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

Moe Ghashim
Moe Ghashim
10,460 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,268 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,659 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,268 Points

Yes sir! I corrected my answer.

Antti Lylander
Antti Lylander
9,659 Points

You are going great but credit is not defined.

hint:

this.credits = credits;