The isNaN function seems not work in Build a Library project

after all the coding and correct it following the video, I found the ‘set numberOfStudents’ snippet is not working, In the practice after the number 514, it works well, but even I input ‘no’ instead of 514, the code still output the ’ Lorraine Hansbury educates no students at the primary school level.’ but it should come to ‘Invalid input: numberOfStudents must be set to a Number.’

could you please help to check where goes wrong? thanks. the link is build a library

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(input){
console.log(‘Invalid input: numberOfStudents must be set to a Number.’);

} else {
 return this._numberOfStudents = input;


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

static pickSubstituteTeacher(substituteTeachers){
let index = Math.floor(Math.random() * substituteTeachers.length);
return substituteTeachers[index];

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 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 sub = 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’]);

You should pass the value you want to check is a number to the function instead. Example: isNaN(valueToCheckHere)

1 Like