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!

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

Roald Jurrian Kamman
.a{fill-rule:evenodd;}techdegree seal-36
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,542 Points

conditional statement not returning correct student level but why? This should work.

Hey everyone,

I'm pretty sure that my conditional statement isn't wrong. Instead of going from high number to low I flipped it since it's running one line of code at a time anyway. Just so I don't need to check the in-between numbers when starting at 90. I had the idea that was a better way of doing it.

Sometimes treehouse challenges are just plainly not recognizing a different way of doing the right thing. I wonder if this is yet another one of those cases.

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

    get level() {
      let creds = this.credits;
      if (creds <= 30) {
        return "they are a 'Freshman'.";
      } else if (creds <= 60) {
        return "they are a 'Sophmore'.";
      } else if (creds <= 90) {
        return "they are a 'Junior'.";
      } else if (creds > 90) {
        return "they are a 'Senior'.";

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

const student = new Student(3.9);

3 Answers

In addition to correcting the spelling of Sophomore you should just return the level. This is the value in single quotes. For example:

return 'Freshman';

instead of

return "they are a 'Freshman'.";

Roald Jurrian Kamman It works however it seems as though you misspelled Sophomore which is why it is not working when you try and submit.