Hi, i have a question , so the matter is that why when i use static
at the end i have assign it to something then console log that think , because when i do it directly it will give me undefiend
for example =
static pickSubstituteTeacher(SubstituteTeachers) {
const random = Math.floor(Math.random() * SubstituteTeachers.length);
return SubstituteTeachers[random];
}
and for the output when i did this=
school.pickSubstituteTeacher([
"Jamal Crawford",
"Lou Williams",
"J. R. Smith",
"James Harden",
"Jason Terry",
"Manu Ginobli",
]);
console.log(PrimarySchool.SubstituteTeachers);
i got = undefined
but when i assigned it to something and then console logged it i got the output (i just hit the get unstuck button to see the answer so i have no idea why is it like this)
const sub = school.pickSubstituteTeacher([
"Jamal Crawford",
"Lou Williams",
"J. R. Smith",
"James Harden",
"Jason Terry",
"Manu Ginobli",
]);
console.log(sub);
i got the =Jamal Crawford
as the output (I know it’s one of those names because i set it to be randomly given)
but why i had to do that to get the output why not just do it directly ?