Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Hello i think i did everything good but i still didn’t get the result that show in console .
My console show :
71.7
157.1
The first result is true but the second is not why is that ? Please help its been 6 hours my head is killing me

let sum = 0;
function getAverage(scores) {
for (let i = 0; i < scores.length; i++) {
  sum += scores[i];
}
return sum / scores.length;
}

console.log(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]));
console.log(getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]));

Please provide a link to the step when asking a question.

You need to not use global variables like this. It ruins your ability to reuse your functions.

So that is the problem i have used a global variable so that why I did not get the right result.
BIG THANKS TO YOU :heart:

1 Like