Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

I dont know why but i cant pass Step 22. I tried too solv it on my own by i cant.

Your code so far

function getAverage(testScores) {
  const total = testScores.reduce((sum, score) => sum + score, 0);
  const average = total / testScores.length;
  return parseFloat(average.toFixed(1));
}

function getGrade(studentScore) {
  if (studentScore === 100) {
    return "A+";
  } else if (studentScore >= 90 && studentScore <= 99) {
    return "A";
  } else if (studentScore >= 80 && studentScore <= 89) {
    return "B";
  } else if (studentScore >= 70 && studentScore <= 79) {
    return "C";
  } else if (studentScore >= 60 && studentScore <= 69) {
    return "D";
  } else if (studentScore >= 0 && studentScore <= 59) {
    return "F";
  }
}

function hasPassingGrade(studentScore) {
  const grade = getGrade(studentScore);
  return grade !== "F";
}

function studentMsg(testScores, studentScore) {
  const average = getAverage(testScores);
  const studentGrade = getGrade(studentScore);
  const passed = hasPassingGrade(studentScore);

  if (passed) {
    return `Class average: ${average}. Your grade: ${studentGrade}. You passed the course.`;
  } else {
    return `Class average: ${average}. Your grade: ${studentGrade}. You failed the course.`;
  }
}

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

Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Your getAverage() function is using toFixed(). That was not asked. It’s important that you follow the instructions exactly and don’t do anything more than what is asked.

you are doing something that was not asked from you

check a function like studentMsg([33, 44, 55, 66, 77, 88, 99, 100], 92), it should return "Class average: 70.25. Your grade: A. You passed the course."

Thank you that was the problem. ( I just wanted to test with toFixed but i forgot to delete that part)