Hello everyone,
I am currently working on the School Catalogue in the Intermediate Javascript level.
When I try to create a new instance for Primary, I received an error from the "super(“primary”): “this is not defined”.
According to this StackOverflow post, the problem come from the parent class, here School. But I don’t see any problem with it! As someone a clue ?
Thank you very much
class School {
constructor(name,level, numberOfStudents) {
this._name = name;
this._level = level;
this._numberOfStudents = numberOfStudents;
}
set numberOfStudents (newNumber) {
if(newNumber === ‘number’) {
this._numberOfStudents = newNumber;
}
else {
return ‘Invalid input: numberOfStudents must be set to a Number.’;
}
}
get name() {
return this._name;
}
get level() {
return this._level;
}
get numberOfStudents() {
return this._numberOfStudents;
}
quickFacts() {
console.log(${this._name} educates ${this._numberOfStudents} at the ${this._level} school level.
)
}
static pickaSubstituteTeacher(substituteTeacher) {
let substituteTeachers = [substituteTeacher];
let randomNum = Math.floor(Math.random() * substituteTeachers.length);
return substituteTeachers[randomNum];
}
}
class Primary extends School {
constructor(name, numberOfStudents, pickupPolicy) {
super(name);
super(“primary”);
super(numberOfStudents);
this._pickupPolicy = pickupPolicy;
}
get pickupPolicy() {
return this._pickupPolicy;
}
}
class Middle extends School {
constructor(name, numberOfStudents) {
super(name);
super(“middle”);
super(numberOfStudents);
}
};
class High extends School {
constructor(name, numberOfStudents, sportTeams) {
super(name);
super(“high”);
super(numberOfStudents);
this._sportTeams = ;
}
get sportTeams() {
console.log(this._sportTeams);
}
}
const lorraineHansbury = new Primary(“Lorraine Hansbury”, 514, ‘Students must be picked up by a parent, guardian, or a family member over the age of 13.’);