JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

Rowan Blackwood
Rowan Blackwood
4,550 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

Nick Evershed
Nick Evershed
5,536 Points

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
4,550 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!

Nick Evershed
Nick Evershed
5,536 Points

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

Rowan Blackwood
Rowan Blackwood
4,550 Points

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

Nick Evershed
Nick Evershed
5,536 Points

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