Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

the code is correct still its not working tried 100 times

Your code so far

function getAverage(scores) {
  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) {
  const grade = getGrade(score);
  return grade !== "F";
}

function studentMsg(scores, studentScore) {
  const average = getAverage(scores);
  const grade = getGrade(studentScore);
  const passed = hasPassingGrade(studentScore);
  return `Class average: ${average.toFixed(1)}. Your grade: ${grade}. You ${passed ? "passed" : "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/136.0.0.0 Safari/537.36

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Hi @aishwarya5007 and welcome to our community!

Your code is absolutely fine except that you don’t need to use the toFixed method.

no still its not working

function getAverage(scores) {
const total = scores.reduce((sum, score) => sum + score, 0);
return Math.round((total / scores.length) * 10) / 10;
}

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) {
const grade = getGrade(score);
return grade !== “F”;
}

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

return Math.round((total / scores.length) * 10) / 10;

You do not need to round the result.