Hi everyone, i have an issue in this step. I feel like i am missing something because my code does not pass. This is what i have:
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";
}
// User editable region
function studentMsg(totalScores, studentScore) {
if(hasPassingGrade(studentScore))
{
return ("Class Average: " + getAverage(totalScores) + ". Your grade:" + getGrade(studentScore) + ". You passed the course.");
}
else
{
return ("Class Average: " + getAverage(totalScores) + ". Your grade: " + getGrade(studentScore) + ". You failed the course.");
}
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
the output i see is this:
// running tests 1. 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."
. 2. 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."
. 3. 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.
also i would want to apologise if this question has already been answered. Thanks a lot for your time!