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

Rowan Blackwood
Rowan Blackwood
5,220 Points

Unexpected string...

So I have been through just about every question and answer and I feel like my implementation should be correct, but I'm guessing I'm missing something here. Anyone got any ideas? The error I get is 'Bummer: Unexpected string'

Thanks

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

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

  get level() {    
    if (this.credits > 90) {
      return 'Senior';
    } else if (this.credits <= 90 && this.credits >= 61) {
      retun 'Junior';
    } else if (this.credits <= 60 && this.credits >= 31) {
      return 'Sophomore';
    } else if (this.credits <= 30) {
      return 'Freshman';
    }
  }
}

const student = new Student(3.9, 50);

3 Answers

It would probably be much more helpful if you could actually see the output of your code, try use this resource https://repl.it/repls/EssentialSelfreliantLock

Rowan Blackwood
Rowan Blackwood
5,220 Points

hahaha :facepalm: school boy error. It's always the typo's that cause the biggest headaches! The funniest bit is it's even highlighted in the editor. What a donut. Thanks for your help!

No worries! if you found it useful, please mark as 'Best Answer'

Rowan Blackwood
Rowan Blackwood
5,220 Points

Worth it just for the repl.it tip ;) Thanks again

Its funny because another user on treehouse actually helped me by suggesting this resource, i'm just passing the resource along now