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

William Domenech
William Domenech
7,259 Points

i dont know whats wrong here

i feel like i am missing something simple

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

    }
        get level(){

          if(this.credits < 90){
              return 'Senior';   
          } else if (this.credits >= 61){
              return 'Junior';
          } else if (this.credits >= 31){
              return 'Sophomore';
          } else (){
              return 'Freshman';
          }
      }
    stringGPA() {
        return this.gpa.toString();
    }
}

const student = new Student(3.9);

1 Answer

devvoyage
seal-mask
.a{fill-rule:evenodd;}techdegree
devvoyage
Front End Web Development Techdegree Student 15,200 Points

Hi, William Domenech!

You are doing fantastic, so don't give up quite yet! There are just a couple of minor errors.

First, there's a syntax error at the else that returns Freshman. You have a pair of parentheses after the else. It should look like this:

 } else { // I removed the parentheses here
              return 'Freshman';
    }

The second is a logic error. You're returning "Senior" when they have less than 90 credits, but you should be returning "Senior" when they have more than 90 credits. Switching the < to a > will fix that.

Hope this helps! :sparkles:

William Domenech
William Domenech
7,259 Points

i knew it had to be something minor thanks so much!