School Catalogue

I need help understanding why my output is different from the video walk through.

On the video walk through when he call quickFacts()
// his output is - Lorraine Hansbury educates 514 students at the school primary level.

and my output is - Lorraine Hansbury educates 514 students at the school Lorraine Hansbury level.

I just can’t figure it out why??

Here is my final codes:

//Parent class
class School {
  constructor(name, level, numberOfStudents){
    this._name = name;
    this._level = level;
    this._numberOfStudents = numberOfStudents;
  }
  get name(){
    return this._name;
  }
  get level(){
    return this._name;
  }
  get numberOfStudents(){
    return this._numberOfStudents;
  }
  set numberOfStudents(value){
    if(typeof value === 'string'){
      return this._numberOfStudents = value;
    }else{
      return 'Invalid input: numberOfStudents must be set to a Number.'
    }
  }
  quickFacts(){
    //reference this.property
    console.log(` ${this.name} educates ${this.numberOfStudents} students at the school ${this.level} level. `)
  }
  static pickSubstituteTeacher(substituteTeachers){
   let getSubstituteTeachers =  Math.floor(substituteTeachers.length * Math.random());
    console.log(substituteTeachers[getSubstituteTeachers]);
  }
};

class PrimarySchool extends School {
  constructor(name, numberOfStudents, pickupPolicy){
    super(name, 'primary', numberOfStudents); //pass 'primary' as the argument for the level parameter in the parent constructor.
    this._pickupPolicy = pickupPolicy;
  }
  get pickupPolicy(){
    return this._pickupPolicy;
  }  
};

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

// PrimarySchool instance
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 part seems a bit troubling:

  get level(){
    return this._name;
  }

:slight_smile:

Nice catch…I over look it and after a while everything start to look same. Thanks,

You’re very welcome :slight_smile: