Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

I don’t know why I’m getting the following result;

Class average: NaN Your grade: F You failed the course

Your code so far

function getAverage(scores){
  let sum = 0;
  for(score in scores){
    sum += score
  }
  let averageScore = sum/scores.length
  return averageScore
}
function getGrade(score){
  if(score === 100){
    return "A+"
  }else if(score >= 90){
    return "A"
  }else if(score >= 80){
    return "B"
  }else if(score >= 70){
    return "C"
  }else if(score >= 60){
    return "D"
  }else{
    return "F"
  }
}
function hasPassingGrade(studentScore){
  return getGrade(studentScore) !== "F" 
}
function studentMsg(classAverage,studentScore){
  let average = getAverage(classAverage);
  let grade = getGrade(studentScore);
  let passed = hasPassingGrade(studentScore)

  let message;

if(passed){
  message = `Class average: ${average} Your grade: ${grade} You passed the course.`
}else{
  message = `Class average: ${average} Your grade: ${grade} You failed the course.`
}
return message
}
console.log(studentMsg((92,88,12,77,57,100,67,38,97,89)))

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/18.5 Safari/605.1.15

Challenge Information:

Build a Gradebook App - Build a Gradebook App

It helps if you use standard formatting here.

I would look really carefully at this function call.

Ok i added the square brackets but still not getting the correct output.

Class average: 12345678.9 Your grade: F You failed the course.

I don’t know why the average is showing 12345678.9

Which parts look wrong? Have you investigated those function calls specifically?

I refreshed then i retyped the getAverage function and it worked.
Thanks for your help.

you wrote it here, you may want to check what the value of score is at each iteration