Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

Hello,
I am just curious about what could be wrong, why cant i pass ?
can anyone help please?

Your code so far


// User Editable Region

function getAverage(scores, score) {
 let sum = 0;

 for (const score of scores);
  sum += score;
  
}
  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]));

// 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/116.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

If you look at your console you should see the following error:

Now if you look at your function, you should see that your curly brackets don’t pair up correctly. You have a closing curly bracket following the for loop which closes off your function completely. This is because your for loop should have its own set of curly brackets but you have a semicolon where the opening bracket should be.

You also don’t need the score parameter in your function definition, as it is created by the for loop.

1 Like

You have modified your function

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