The goal is to pass an array of strings (Substitute teacher names) to the 'pickSubstituteTeacher' method and return one random teacher. I cannot figure out how to send an array of strings to the object method and return the random value.
class School {
constructor(name, level, numberOfStudents) {
this._name = name;
this._level = level;
this._numberOfStudents = numberOfStudents;
}
static pickSubstituteTeacher(substituteTeachers) {
let ranNum = Math.floor(Math.random()*substituteTeachers.length);
return substituteTeachers[ranNum];
}
}
const school1 = new School('school1', 'two', 233);
let randomTeacher = School.pickSubstituteTeacher['teacher1','teacher2','teacher3'];
console.log(randomTeacher);
['a','b','c'].pickSubstitudeTeachera static method, so you should be calling it withSchool.pickSubstituteTeacher-- or did you mean to not make it static?