Stumped by School Catalogue

Hello,

I managed to get through the project without any issues. But I’m completely stumped by the last challenge " * Create a class called SchoolCatalog that holds a collection of schools. Create an instance of SchoolCatalog for primary, middle, and high schools."

I couldn’t figure out how to do this even with the hint given in the video walkthrough.

I tried making an array and pushing all class objects to it in the School class constructor, but I have no idea how to add all of those objects to the catalog class.

Here is my code from the project:

const allSchools = []

class School {
  constructor(name,level,numberOfStudents) {
    this._name = name
    if (level === 'primary' || level === 'middle' || level === 'high') {
      this._level = level
    } else {
      console.log('Error: school level must be primary, middle or high')
    }
    if (typeof numberOfStudents === 'number') {
      this._numberOfStudents = numberOfStudents
    } else {
      console.log('Error: number of students must be a number')
    }
    allSchools.push(this)
  }
  
  get name() {
    return this._name
  }
  
  get level() {
    return this._level
  }
  
  get numberOfStudents() {
    return this._numberOfStudents
  }
  
  set numberOfStudents(numberToSet) {
    if (typeof numberToSet === 'number') {
      this._numberOfStudents = numberToSet
    } else {
      console.log('Error: number of students must be a number')
    }
  }
  
  quickFacts() {
    console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`)
  }
  
  static pickSubstituteTeacher(substituteTeachers) {
    let randomIndex = Math.floor(Math.random() * substituteTeachers.length)
    return substituteTeachers[randomIndex]
  }
}

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

class MiddleSchool extends School {
  constructor(name,numberOfStudents) {
    super(name,'middle',numberOfStudents)
  }
}

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


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.")

const alSmith = new HighSchool('Al E. Smith',415,['Baseball','Basketball','Volleyball','Track and Field'])



class SchoolsCatalog {
  constructor() {
  }
}

const allSchoolsCatalog = new SchoolsCatalog()

console.log(allSchoolsCatalog)

This one is a bit tricky and could be approached from a number of angles so don’t take this as a solution, only a scaffold from which to glean ideas.

Example of SchoolCatalog class