Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

A teacher has finished grading their students’ tests and needs your help to calculate the average score for the classComplete the getAverage function which takes in an array of test scores and returns the average score.The average is calculated by adding up all the scores and dividing by the total number of scores.
Example Code average = sum of all scores / total number of scores
You can use a loop to iterate over the scores array and add up all the scores.
You can use the length property to get total number of score
your getAverage should return a number

Your code so far


// User Editable Region

function getAverage(scores) {
let i=0;
while (i < scores.length) {
    console.log(scores[i]);
    i++;
}
}

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]));

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

your getAverage should return a number
what to do?

I can’t explain it any better than the instructions that you’ve posted here.

Do you have a more specific question?