Hi, I have this code for the exercise and the output is correct and the spacing and punctuation looks correct, but its still giving an error.
function getAverage(scores) {
let sum = 0;
for (const score of scores) {
sum += score;
}
return sum / scores.length;
}
function getGrade(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(score) {
return getGrade(score) !== "F";
}
function studentMsg(totalScores, studentScore) {
let a = getAverage(totalScores);
let b = getGrade(studentScore);
if (b !== 'F'){
return ("Class Average: "+ a + ". Your Grade: " + b + ". You passed the course.");
}
else {
return ("Class Average: "+ a + ". Your Grade: " + b + ". You failed 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));
Output is this
// running tests
Your function call of studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37) should return the following message: "Class average: 71.7. Your grade: F. You failed the course.".
Your function call of studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100) should return the following message: "Class average: 50.8. Your grade: A++. You passed the course.".
Your studentMsg function should return the correct message based on the student's score and the class average.
// tests completed
// console output
Class Average: 71.7. Your Grade: F. You failed the course.
Class Average: 50.8. Your Grade: A++. You passed the course.