Tell us what’s happening:
This is bugged, hasPassingGrade returns false and I am still getting the 19th test failed
Your code so far
const getAverage = arr => {
let sum = 0
for (const grade of arr) {
sum += grade
}
return sum / arr.length
}
const getGrade = score => {
if (score === 100) return "A+"
if (score < 60) return "F"
if (score < 70) return "D"
if (score < 80) return "C"
if (score < 90) return "B"
return "A"
}
const hasPassingGrade = grade => grade !== "F"
const studentMsg = (arr, score) => {
if (hasPassingGrade(getGrade(score)) === false) {
return `Class average: ${getAverage(arr)}. Your grade: ${getGrade(score)}. You failed the course.`
} else if (hasPassingGrade(getGrade(score)) === true) {
return `Class average: ${getAverage(arr)}. Your grade: ${getGrade(score)}. 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/140.0.0.0 Safari/537.36
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