Tell us what’s happening:
I’m getting the correct output but I failing test 17, 20, 21, and 22.
Your code so far
function getAverage(array){
let average = (array.reduce((acc, num) => acc + num, 0)) /array.length;
console.log(average);
return average;
};
getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]);
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 if (score>=0 && score<=59){
return "F";
}
};
function hasPassingGrade(grade) {
return grade !== "F";
}
function studentMsg(scoreArray, studentScore) {
if (getGrade(studentScore) !== "F") {
return "Class average: " + getAverage(scoreArray) + ". " + "Your grade: " + getGrade(studentScore) + ". " + " You passed the course.";} else{
return "Class average: " + getAverage(scoreArray) + ". " + "Your grade: " + getGrade(studentScore) + ". " + " You failed the course.";
}
}
console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
When i use this:
function hasPassingGrade(grade) {
return [“A+”, “A”, “B”, “C”, “D”].includes(grade);
}
16 and 18 fail. 17 passes/
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App