School Catalogue


Hi, I’m hoping someone can clarify my code. I’ve just finished everything from the School Catalogue project, and it works! Where I’m confused is if I comment out my last console.log statement, all of my results are undefined:

class School {
  constructor(name, level, numberOfStudents){
    this._name = name;
    this._level = level;
    this._numberOfStudents = numberOfStudents;
  get name(){
    return this._name;
  get level(){
    return this._level;
  get numberOfStudents(){
    return this._numberOfStudents;
  set numberOfStudents(newNumberOfStudent){
    if(newNumberOfStudents === number){
      this._numberOfStudents = newNumberOfStudents;
    } else {
      console.log(`Invalid input: ${this._numberOfStudents} must be set to a Number.` )
    console.log(`${this._name} educates ${this._numberOfStudents} students at the ${this._level} school level.`)
  static pickSubstituteTeacher(substituteTeachers){
    let substituteTeacherIndex = Math.floor(Math.random() * substituteTeachers.length -1)
    return substituteTeachers[substituteTeacherIndex]

class PrimarySchool extends School{
  constructor(name, numberOfStudents, pickupPolicy){
  super (name);
  this._level = 'primary';
  this._numberOfStudents = numberOfStudents;
	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;

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

console.log(School.pickSubstituteTeacher(['Jamal Crawford', 'Lou Williams', 'J. R. Smith', 'James Harden', 'Jason Terry', 'Manu Ginobli']));

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


Could someone please explain how my last console.log statement (alSmith.sportsTeams) “allows” my previous, “console.log(School.pickSubstituteTeacher([‘Jamal Crawford’, ‘Lou Williams’, ‘J. R. Smith’, ‘James Harden’, ‘Jason Terry’, ‘Manu Ginobli’]));” to produce a result? I’m confused as to why, when I comment out console.log(alSmith.sportsTeams), all other logs are undefined with the exception of “console.log(lorraineHansbury.quickFacts());”

How does one log impact the other?



Please disregard. Total brainfart. However, I am still receiving an undefined result logged to my console:

“Lorraine Hansbury educates 514 students at the primary school level.
Jason Terry
[ ‘Baseball’, ‘Basketball’, ‘Volleyball’, ‘Track and Field’ ]”

I’m guessing this is because within lorraineHasbury PrimarySchool instance, there’s a pickupPolicy string (‘Students must be picked up by a parent, guardian, or a family member over the age of 13.’) that does not exist within the quickFacts method?


methods and function always return undefined, unless you use the return keyword to return something else.

you don’t use return in quickFacts method, so the default value (undefined) is returned, by calling console.log on quickFacts function call, you log the returned result (undefined) to the console