Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

cant get it to work , i keep failing the last part:

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

Your code so far

// 1. getAverage function
function getAverage(scores) {
  let total = scores.reduce((sum, score) => sum + score, 0);
  return parseFloat((total / scores.length).toFixed(1)); // rounding to 1 decimal place
}

// 2. getGrade function
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";
}

// 3. hasPassingGrade function
function hasPassingGrade(score) {
  const grade = getGrade(score);
  return grade !== "F";
}

function studentMsg(classScores, studentScore) {
  const average = getAverage(classScores);
  const grade = getGrade(studentScore);
  const passed = hasPassingGrade(studentScore);

  let courseResult;
  if (passed) {
    courseResult = "You passed the course.";
  } else {
    courseResult = "You failed the course.";
  }

  return "Class average: " + average + ". Your grade: " + grade + ". " + courseResult;
}





Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Welcome to the forum @Dustin-F

Try using two decimal places.

Happy coding

you are not asked to do this, do not round

Thank you so much it worked

1 Like

Hi @Dustin-F

As @ILM mentioned, you were not asked to round the numbers.
I was debugging by altering you code, as the output seemed to look right.

Happy coding