Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
Asking for the initialization of 'Exams'. But how to.. ? Please help me to solve it out! Thanks in advance!
var exam1 = 74; var exam2 = 80; var exam3 = 68; console.log(Exams.average(exam1, exam2, exam3)); class Exams{ static average(a, b, c){ return Math.round((a + b + c)/3); } };
5 Antworten
+ 4
Move class `Exams` definition up before the line where Exams.average() was invoked. I'm just guessing class definition must preceed its usage.
+ 3
Sony,
Move your function call
console.log(Exams.average(exam1, exam2, exam3));
To beneath the class definition and it runs fine 👍.
You can’t use hoisting with an unitialized class, this is because the class could be extended. Hopefully that makes sense.
+ 1
Ipang outstanding... :) Bravo!! Thanks to all..
+ 1
DavX yeah.. it's Indeed!! Thanks!
0
But in output, it's asking for the 'Exams' initialization..? Mirielle