Tell us what’s happening:
“Your hasPassingGrade function should return false if the grade is an “F””
I keep getting this error for step 19 - even though my code is passing the last steps that call the studentMsg function in which an "F’ is used and working in my hasPassingGrade function. I am either overlooking something obvious or there is a bug. My code for the function:
Your code so far
function getAverage(arr) {
const sum = arr.reduce(
(accumulator, currentValue) => accumulator + currentValue,
0,
);
return sum / arr.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(score) {
if ( score === "F") {
return false
}
return true
}
function studentMsg(arr, num) {
const average = getAverage(arr);
const grade = getGrade(num);
const passed = hasPassingGrade(grade) ? 'passed' : 'failed'
return `Class average: ${average}. Your grade: ${grade}. You ${passed} the course.`
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App