JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

Jesus Mendoza
Jesus Mendoza
Full Stack JavaScript Techdegree Student 15,707 Points

Unexpected token >=

I can't figure out what I'm doing wrong here. "Unexpected token >=" keeps popping up.

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

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

    get level() {
            const studentCredits = this.credits;

        if ( studentCredits >= 90) {
            return 'Senior';
        } else if ( studentCredits <= 90 && >= 61) {
                return 'Junior';
        } else if ( studentCredits <= 60 && >= 31) {
                return 'Sophomore';
        } else if ( studentCredits <= 30) {
                return 'Freshman';


const student = new Student(3.9);

1 Answer

Jason Anders
Jason Anders
Treehouse Moderator 144,853 Points

Hi Jesus,

The error is not very detailed, but it is telling you that something right before the symbols >= in the code is wrong. There are 3 instances of this symbol. The first one is the if conditional to compare studentCredits to 90. This one is fine.

The error is occurring in the first else if conditional (and will also occur in the third). When using boolean operators (her the &&), you have to tell the compiler what you are comparing one to the other on both sides of the operator.


variableToCompare >= value1 && <= value2

Will return an error. The compiler has no idea what to compare value2 to. So, it you need to repeat the variable that is comparing to. Like

variableToCompare >= value1 && variableToCompare <= value2

Once you fix up those two instances, the rest looks good.

Nice work! :) :dizzy: