Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

I still cannot pass the 22nd requirement. Please help me.

Your code so far

function getAverage(scores) {
  if (scores.length === 0) return 0;
  const total = scores.reduce((sum, score) => sum + score, 0);
  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(scoresArray, studentScore) {
  const average = getAverage(scoresArray);
  const averageRounded = parseFloat(average.toFixed(1));
  const grade = getGrade(studentScore);
  if (hasPassingGrade(studentScore)) {
    return `Class average: ${averageRounded}. Your grade: ${grade}. You passed the course.`
  } else {
    return `Class average: ${averageRounded}. Your grade: ${grade}. You failed the course.`
  }
}

console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

What is the 22nd requirement? Which part of your code do you think satisfies the 22nd requirement?

Were you asked to do this in the instructions?

  1. Your studentMsg function should return the correct message based on the student’s score and the class average.

My code doesn’t pass through this checkpoint.

The average mark should return in 1 decimal place.

Nowhere in the instructions did it say that.

1 Like