JavaScript Object-Oriented JavaScript Getters and Setters Creating Getter Methods

I don't understand how to write an empty Getter

It asks for an empty getter but when I write the code I continue to get an unexpected token. I'm really confused because the videos show one way but you have to write code another way.

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

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

const student = new Student(3.9);

1 Answer

You need to include the getter inside the class

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

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

  get level() {

  }
}

const student = new Student(3.9);