[School Catalogue, .quickFacts()] String interpolation resulting in undefined values in step 15

Link: https://www.codecademy.com/paths/build-web-apps-with-react/tracks/bwa-javascript-iterators-objects-and-classes/modules/learn-javascript-classes/projects/school-catalog

Hello,

I am working on JavaScript: Classes project and I got stuck by the step 15, where my strings are logged as “undefined educates undefined students at the undefined school level”-the result of the very last method call. I’ve already referred to the walk-through video, but still couldn’t find out what’s gone wrong. I could use some help. Thank you in advance. My codes are as the below:

// Superclass - School
class School {
  consturctor(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 (value) {
    if (isNan(value)) {
    	console.log("Invalid input: numberOfStudents must be set to a Number.")
    } else {
      this._numberOfStudents = value; 
    }
  }
  
  quickFacts () {
    console.log(`${this.name} educates ${this.numberOfStudents} students at the ${this.level} school level.`);
  }
  
  static pickSubstituteTeacher (substituteTeachers) {
    let teacherIndex = Math.floor(Math.random() * substituteTeachers.length-1);
    return substituteTeachers[teacherIndex];
  }
}

// Subclass 1 - Primary
class PrimarySchool extends School {
  constructor(name, numberOfStudents, pickupPolicy) {
    super(name, "primary", numberOfStudents);
    this._pickupPolicy = pickupPolicy;
  }
  
  get pickupPolicy () {
    return this._pickupPolicy;
  }
}

// Subclass 3 - High
class HighSchool extends School {
  constructor(name, numberOfStudents, sportsTeams) {
    super(name, "high", numberOfStudents);
    this._sportsTeams = sportsTeams;
  }
  
  get sportsTeams () {
    console.log(this._sportsTeams);
  }
}

// Instance 1
const lorraineHansbury = new PrimarySchool("Lorraine Hansbury", 514, "Students must be picked up by a parent, guardian, or a family member of the age of 13.")
console.log(lorraineHansbury);

Same issue as in the other topic, have you verified the school constructor actually works?

You may want to kick yourself after, but check your spelling very, very carefully in your School constructor method. :wink:

Thank you. I’ve just kicked myself :slight_smile:

1 Like