School Catalogue Project, Issue with Adding Average Test Score reducer and array push

Hello, I wanted to do some extra practice on School Catalogue project.

I tried making a getAverageScore function, but when I call it as alSmith.getAverageScore, it returns “[Function: getAverageScore]”.

Here is my code, thank you in advance for your guidance:

class School {
  constructor(name, level, numberOfStudents, testScores) {
    this._name = name;
    this._level = level;
    this._numberOfStudents = numberOfStudents;
    this._testScores = [];
  }

  get name() {
    return this._name;
  }

  get level() {
    return this._level;
  }

  get numberOfStudents() {
    return this._numberOfStudents;
  }

  get testScores() {
    return this._testScores;
  }

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

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

  static pickSubstituteTeacher(substituteTeachers) {
    const random = Math.floor(Math.random() * substituteTeachers.length);
    console.log(substituteTeachers[random]);
  } 

  getAverageScore() {
    const testScoresSum = this.testScores.reduce((accumulator, current) => accumulator + current);
    return testScoresSum / this.testScores.length;
  }

  addTestScore(value) {
    this.testScores.push(value);
  }

}

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() {
    console.log(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']);


alSmith.addTestScore(100);
alSmith.addTestScore(0);
alSmith.addTestScore(10);
alSmith.addTestScore(80);
alSmith.addTestScore(50);
alSmith.addTestScore(65);

console.log(alSmith.getAverageScore);

here:

console.log(alSmith.getAverageScore);

you are merely referencing the getAverageScore method, you are not actually calling/invoking the method

thank you, i forgot it’s not a getter and needs the parentheses!

I also had a question about constructors, but nobody seems to have gotten back to me about it. If you have a chance, can you go over here

because getting a handle on classes depends on knowing which parameters to fill into a constructor, and I’m not exactly sure what the rule is for what parent properties are inserted into child constructor parameters. It seems to change every time.

I sent you a DM/PM (direct message/personal message) about that topic, The missing information (full code, exercise url) would mean a lot of extra trouble. So I left it open for someone else, or you could edit the topic