Hey everyone ![]()
I’m working on the Gradebook App challenge
All my tests pass except for test #19, which says:
“Your hasPassingGrade function should return false if the grade is an ‘F’.”
const getAverage = (arr) => {
let total = 0;
for (let i = 0; i < arr.length; i++) {
const grade = arr[i];
total += grade / arr.length;
}
return total;
};
const getGrade = (grade) => {
if (grade === 100) return 'A+';
else if (grade >= 90 && grade <= 99) return 'A';
else if (grade >= 80 && grade <= 89) return 'B';
else if (grade >= 70 && grade <= 79) return 'C';
else if (grade >= 60 && grade <= 69) return 'D';
else return 'F';
};
const hasPassingGrade = (score) => score !== "F"
const studentMsg = (scores, studentScore) => {
const avgScore = getAverage(scores);
const grade = getGrade(studentScore);
const passing = hasPassingGrade(grade);
return passing
? `Class average: ${avgScore}. Your grade: ${grade}. You passed the course.`
: `Class average: ${avgScore}. Your grade: ${grade}. You failed the course.`;
};
So, in the console it behaves exactly as expected — but test #19 still fails.
Does anyone know why FreeCodeCamp might not be accepting this test?
Thanks in advance ![]()