Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Tell us what’s happening:

my code is giving a undefined in between the correct answers and i do not know where they are comming from.

Your code so far


// User Editable Region


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

// 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/133.0.0.0 Safari/537.36 Edg/133.0.0.0

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 1

Hi and welcome to the forum.

Are you getting an error? Can you share the error?

You can return or you can log to the console, but I don’t think you can do both at the same time.

no i am not getting a error this is my result:

thank you for the help

1 Like