Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

Hey, it keeps saying my getAverage function should have a return value, I already looked at other post and the “How to add numbers in a javascript array” link, but no matter how I arrange it, it keeps saying my code doesn’t pass. Am I missing something?

Your code so far


// User Editable Region

function getAverage(scores) {
  let sum = 0;
  for (let i = 0, i < scores.length, i++){
  scores += scores.length;
  }
  return average = sum of all scores/total number of scores;
}

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/605.1.15 (KHTML, like Gecko) Version/15.6.1 Safari/605.1.15

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

this is a syntax error all on its own

scores is an array, if you do this it’s not an array anymore. You should add to sum instead, and add the elements of scores (accessed with bracket notation` to it

1 Like

Okay, thank you, I will fix that.

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