Tell us what’s happening:
Hi, please i don’t know why i keep getting error ‘Your hasPassingGrade function should return false if the grade is an “F”.’
function hasPassingGrade(grade){
if (grade === “F”) return false;
return true;
}
Your code so far
const scores = [92, 88, 12, 77, 57, 100, 67, 38, 97, 89];
;
function getAverage(scoresArr){
let totalScores = 0;
for(let num of scoresArr){
totalScores +=num;
}
let averageScore = totalScores/scoresArr.length;
return averageScore;
}
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";
return "F";
}
function hasPassingGrade(grade){
if (grade === "F") return false;
return true;
}
function studentMsg(scoresArr,studentScore){
const averageScore = getAverage(scoresArr);
let studentGrade = getGrade(studentScore);
let hasPassed = hasPassingGrade (studentGrade);
if(hasPassed){
return `Class average: ${averageScore}. Your grade: ${studentGrade}. You passed the course.`
}
return `Class average: ${averageScore}. Your grade: ${studentGrade}. You failed the course.`
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App