Tell us what’s happening:
I don’t even know what is the problem, the test 19 just doesn’t accept my code, even tho it only shows false to F on the hasPassingGrade(F) log.
Your code so far
function getAverage(scores) {
let sum = 0;
for (const score of scores) {
sum += score;
}
return sum / scores.length;
}
function getGrade(score) {
if (score === 100) {
return "A+";
} else if (score >= 90 && score <= 99) {
return "A";
} else if (score >= 80 && score <= 89) {
return "B";
} else if (score >= 70 && score <= 79) {
return "C";
} else if (score >= 60 && score <= 69) {
return "D";
} else {
return "F"
}
}
function hasPassingGrade(grade) {
return String(grade).toUpperCase() !== "F";
}
function formatAverage(avg) {
if (avg % 1 === 0) return avg.toFixed(0);
if ((avg * 10) % 1 === 0) return avg.toFixed(1);
if ((avg * 100) % 1 === 0) return avg.toFixed(2);
return avg.toFixed(3);
}
function studentMsg(totalScores, studentScore) {
const average = getAverage(totalScores);
const grade = getGrade(studentScore);
const avgStr = formatAverage(average);
if (grade !== "F") {
return "Class average: " + avgStr + ". Your grade: " + grade + ". You passed the course.";
} else {
return "Class average: " + avgStr + ". Your grade: " + grade + ". You failed the course.";
}
}
console.log(hasPassingGrade("F"));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:143.0) Gecko/20100101 Firefox/143.0
Challenge Information:
Build a Gradebook App - Build a Gradebook App
https://www.freecodecamp.org/learn/full-stack-developer/lab-gradebook-app/build-a-gradebook-app