Can't get the code running in JavaScript Syntax: Classes

I even tried following the video on the page. I don’t know what I’m doing wrong, or if there is something not working on Codecademy’s end. Here’s my code:

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(value) {
if (value.isNaN()) {
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) {
const randInt = Math.floor(Math.random() * substituteTeachers.length);
return substituteTeachers[randInt];
}
}

class primarySchool 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 lorrainHansbury = new primarySchool(‘Lorraine Hansbury’, 514, ‘Students must be picked up by a parent, guardian, or a family member over the age of 13.’);
lorrainHansbury.quickFacts();

const sub = School.pickSubtituteTeacher([‘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’]);
console.log(alSmith.sportsTeams);

}

Here’s the link to the project on Codecademy:

https://www.codecademy.com/journeys/full-stack-engineer/paths/fscj-22-front-end-development/tracks/fscj-22-javascript-syntax-part-iii/modules/wdcp-22-learn-javascript-syntax-classes-8d95f6d1-ff64-43c3-8ff7-cdc933e16fde/projects/school-catalog

The last } is in the wrong place.
It ends the HighSchool class, so it should be before
const lorrainHansbury

You have a typo here:

School.pickSubtituteTeacher
should be
School.pickSubstituteTeacher

Next time, please use the </> button and paste the code on lines between the
``` and ``` so that the code keeps its formatting.

2 Likes

It works. Thanks a lot.

Really nice of you to take the time to help me. I appreciate it.

1 Like