Tell us what’s happening:
I have tried all possible means to pass the code, but is still showing me that hasPassingGrade function should return false if the grade is an “F” which It did but the code is not passing.
Your code so far
function getAverage(arr){
let sum = 0;
for(const obj of arr){
sum += obj;
}
return sum/arr.length;
};
const getGrade = function (score){
if(score === 100){
return "A+";
}
else if(score >=90){
return "A";
}
else if(score >=80){
return "B";
}
else if(score >=70){
return "C";
}
else if(score >=60){
return "D";
}
else{
return "F";
}
};
function hasPassingGrade(grade) {
return grade !== "F";
};
function studentMsg(scores, studentScore) {
const average = getAverage(scores);
const grade = getGrade(studentScore);
const status = hasPassingGrade(grade) ? "passed" : "failed";
return `Class average: ${average}. Your grade: ${grade}. You ${status} the course.`;
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App