Build a Grade Book App - Step 16

I can’t for the life of me get step 16 to pass. The test runner keeps saying “A” is not passing true.
Link to the project = https://www.freecodecamp.org/learn/full-stack-developer/lab-gradebook-app/build-a-gradebook-app

Any help would be appreciated.

Here is my code:

function getAverage(testScores) {
  let total = 0;
  if (testScores.length === 0) return "No test score provided";
  return testScores.reduce((sum, score) => sum + score, 0) / testScores.length;
}
//console.log(getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]));

function getGrade(studentScore) {
  if (studentScore === 100) return "A+";
  if (studentScore >= 90) return "A";
  if (studentScore >= 80) return "B";
  if (studentScore >= 70) return "C";
  if (studentScore >= 60) return "D";
  if (studentScore >= 0) return "F";
  return "error";
}
console.log(getGrade(99));

function hasPassingGrade(score) {
  return score === "A+" ||score === "A" || score === "B" || score === "C"
}
console.log(hasPassingGrade(getGrade()));

function studentMsg(scores, studentScore) {
  let averageScore = getAverage(scores);
  //console.log(averageScore);
  let letterGrade = getGrade(studentScore);
//console.log (letterGrade);

if (["A+", "A", "B", "C"].includes(letterGrade)) {
  return `Class average: ${averageScore}. Your grade: ${letterGrade}. You passed the course.`;
}
return `Class average: ${averageScore}. Your grade: ${letterGrade}. You failed the course.`;

}
//console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37))

can you please share a link to the project you are doing?

Sure, I added it to the original post i made.

Thanks for the assist!

Look at the way you’re writing the “if else” statement. I think your syntax might be a bit off.

Sorry, Can you specify which If/else?
I don’t have any else statements as all my Ifs since once the condition is met the code auto exits.
So i didn’t think i had to add else statments.

Thanks for the help!

I see what you mean! That went completely over my head. Thanks for clarifying that.

1 Like

The hasPassingGrade function should use the getGrade function to get the letter grade,

Look at what you are passing to that function, with console.log(score) inside the function.

1 Like

Awesome. That did it!

1 Like