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

I can't seem to get the right answer here. any help?

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

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

    get level() {
      const credits = this.credits;
      if (credits > 90) {
        return 'Senior';
      } else if (credits >= 61) {
        return 'Junior';
      } else if (credits >= 31) {
        return 'Sophmore';
      } else {
        return 'Freshman';
      }
    }

}

const student = new Student(3.9, 50);

console.log(student.level);

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

HI Daniel Kolb

You do have it!! :) You simply have a spelling error in one the the levels.
You have "Sophmore" that is missing an "o" — Just correct the spelling to "Sophomore" and it will pass.

It'd be good to remember that code challenges are very strict and very picky. One spelling error or a missing punctuation mark, or anything else that is not specified in the instructions will result in a "Bummer!" message even if the code is correct.

Keep coding! :) :dizzy:

Steven Parker
Steven Parker
231,248 Points

I would add that programming in general is "very picky". A misspelled variable name or comparison value will almost always prevent code from working as intended.

But the challenges are indeed picky about other aspects of the conditions given in the instructions, like the contents of displayed strings which would cause no errors in actual practice.