Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

I think I almost have it but I can’t tell what the issue is. When the code is run I get this in the console:

71.7
undefined
85.4
undefined

I assume the undefined is why my code isn’t passing, because the averages are correct but I’m not sure what is causing it to pop up. Thanks in advance!!

Your code so far


// User Editable Region

function getAverage(scores) {
  let sum = 0;
  
  for (let i = 0; i < scores.length; i++){
    sum += scores[i];
  }
console.log(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]));

// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

You’re going to laugh.

You’re asked for the function to return the average score, not log it to the console.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.