Here’s a link to the School Catalog Project in Intermediate JavaScript: https://www.codecademy.com/courses/learn-intermediate-javascript/projects/school-catalog
I have followed the instructions completely, even followed the video walkthrough, but I somehow cannot locate the error in my code. I cannot access properties of my class, it keeps returning undefined. Here’s my code, someone please help:
class School{
construtor(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(numst){
if (typeof numst === int){
this._numberOfStudents = numst;
} else{
console.log( 'Invalid input: numberOfStudents must be set to a Number.');
}
}
quickFacts() {
console.log(`${this.name} educates ${this.numberOfStudents} at the ${this.level} school level.`);
}
static pickSubstituteTeacher(substitutes){
substitutes = [];
let rand= Math.floor((Math.random()*(substitutes.length)));
return substitutes[rand];
}
}
class Primary extends School{
constructor(name, numberOfStudents, pickupPolicy){
super(name, "primary", 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 shimoTewa = new Primary ("Shimo La Tewa", 56, "After5");
shimoTewa.quickFacts();
School.pickSubstituteTeacher(['Jamal Crawford', 'Lou Williams', 'J. R. Smith', 'James Harden', 'Jason Terry', 'Manu Ginobli']);
const smith = new HighSchool('Al E. Smith', 425, ['Baseball', 'Basketball', 'Volleyball', 'Track and Field']
);
smith.quickFacts();
console.log(smith.sportsTeams);
console.log(smith.name)
Here’s the output to the above code:
Output:
undefined educates undefined at the undefined school level.
undefined educates undefined at the undefined school level.
[ ‘Baseball’, ‘Basketball’, ‘Volleyball’, ‘Track and Field’ ]
undefined