Help with "School Catalogue" project

Hi all, wondering if you can help me understand where i’m going wrong?

This code should be exporting the following to the console:

Lorraine Hansbury educates 514 students at the primary school level.

but i’m getting “undifined” for the variables passed to the parent class :

undefined educates undefined students at the undefined school level.

FULL CODE BELOW:

class School {
  constructer(name,level,numberOfStudents){
    this._name = name;
    this._level = level;
    this._numberOfStudents = numberOfStudents  
  }

//GETTERS AND SETTERS
  get name(){
    return this._name
  }

  get level(){
    return this._level
  }

  get numberOfStudents(){
    return this._numberOfStudents
  }

  set numberOfStudents(newNumberOfStudents){
    if (typeof newNumberOfStudents === 'number' ){
      this.numberOfStudents = newNumberOfStudents
    } else {
      console.log('Invalid input: numberOfStudents must be set to a Number.')
    }
  }

//METHODS
  quickFacts() {
    console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`)
  }

 static pickSubstituteTeacher(substituteTeachers){ 
   let rand = Math.floor(Math.random() *      substituteTeachers.length - 1)
   return substituteTeachers[rand];
 }

}//close School class

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

  get pickupPolicy(){
    return this._pickupPolicy;
   }

}// close Primary Class

class Middle extends School {

}//Close Middle Class


//Highschool 
class HighSchool extends School {
  constructor(name, numberOfStudents, sportsTeams){
    super(name,'high',numberOfStudents);
    this._sportsTeams = sportsTeam;
   }

get sportsTeams() {
  return this._sportsTeams;
}

}//Close High Class

const lorraineHansbury = new PrimarySchool('Lorraine Hansbury', 514, 'Students must be picked up by a parent, guardian, or a family member over the age of 13.');

lorraineHansbury.quickFacts();

This could a problem with the constructors, that the instance variable (or whatever they are called in JS) are not initialized properly.

lets find out:

constructor(name, numberOfStudents, pickupPolicy){
    console.log('primary school constructor');
    super(name,'primary',numberOfStudents);
    this._pickupPolicy = pickupPolicy;
  }

We see the desired information logged to the console. So what about the parent constructor?

  constructer(name,level,numberOfStudents){
    console.log('school constructor');
    this._name = name;
    this._level = level;
    this._numberOfStudents = numberOfStudents  
  }

nothing is logged. How could this be? the super() call looks fine. So focus on your School constructor.

Aha!!! I found it… I can’t spell… I’d put constructEr instead of constructOr.

In this case, how come it wouldn’t throw an error. I’d expect some kind of “unknown” error on “constructer” (with the incorrect spelling)

I hope my answer also teaches you how to debug this kind of issues. Using a debugger would be even cleaner :slight_smile: But that is something for later

once you are done with codecademy, use a spell check on your editor, prevents this kind of mistakes.

this has to do with the philosophy of JS. Errors would interrupt the users browser experience, as such JS tries to make the best of things. But in my opinion, this just leads to errors further down the line which are now harder to trace

It was very helpful, Thank you!