Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

All the tests pass except for test 22:
// running tests
22. Your studentMsg function should return the correct message based on the student’s score and the class average.
// tests completed

Your code so far

function getAverage(scores) {

  let total=0;
  for(let score of scores){
    total += score;
  }
  return total / scores.length;
}

function getGrade(score) {
  if (score === 100) return "A+";
  if (score >= 90) return "A";
  if (score >= 80) return "B";
  if (score >= 70) return "C";
  if (score >= 60) return "D";
  return "F";
}

function hasPassingGrade(score) {
  return getGrade(score) !== "F";
}

function studentMsg(scores, studentScore) {
  const average = getAverage(scores).toFixed(1);
  const grade = getGrade(studentScore);
  const passed = hasPassingGrade(studentScore);
  if(passed){
    return `Class average: ${average}. Your grade: ${grade}. You passed the course.`
  }else{
    return `Class average: ${average}. Your grade: ${grade}. You failed the course.`
  }
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0

Challenge Information:

Build a Gradebook App - Build a Gradebook App

There’s no need to round the average. It’s coincidence that both examples have one decimal digit.

thx, problem solved :wink: