Learn Javascript Classes School Catalogue


#1

I am receiving an error here, and I don’t understand why:
/home/ccuser/workspace/learn-javascript-classes-school-catalog/app.js:43
super(numberOfStudents);
^
ReferenceError: this is not defined
at new PrimarySchool

This is the code I have:
class School {
constructor(name, numberOfStudents, level) {
this._name = name;
this._numberOfStudents = numberOfStudents;
this._level = level;
}

class PrimarySchool extends School {
constructor(name, numberOfStudents, pickupPolicy) {
super(name);
super(numberOfStudents);
this._level = ‘primary’;
this._pickupPolicy = pickupPolicy;
}


#2

I figured it out. It should be super(name, numberOfStudents)