JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

Aziz Kemal HOSCAN
Aziz Kemal HOSCAN
Full Stack JavaScript Techdegree Student 8,036 Points

Need help on solving this problem

I can not see the problem. I am not sure if its the syntax of class or conditional statement.

creating_getters.js
class Student {
    constructor(gpa, credits){
        this.gpa = gpa;
        this.credits = credits;
    }

    stringGPA() {
        return this.gpa.toString();
    }

    get level() {



      if(credits > 90 ) {
        return 'Senior';
      } else if(credits <= 90 && credits >= 61) {
        return 'Junior';           
      } else if (credits <= 60 && credits >=31) {
        return 'Sophomore';
       } else {
         return 'Freshman';
    }
}

const student = new Student(3.9);

2 Answers

Steven Parker
Steven Parker
180,223 Points

I see two issues:

  • you need a "this." prefix when referencing "credits" (in 5 places)
  • there is a closing brace missing at the end of the method