Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

Hi,

I’m having an issue with my studentMsg function. It is supposed to return the correct message based on the student’s score and the class average, but I’m not sure if it’s working correctly.

Here’s my code:

Your code so far

function getAverage(scores) {
    const total = scores.reduce((sum, score) => sum + score, 0);
    return total / scores.length;
}

function getGrade(score) {
    if (score === 100) return "A+";
    if (score >= 90) return "A";
    if (score >= 80) return "B";
    if (score >= 70) return "C";
    if (score >= 60) return "D";
    return "F";
}

function hasPassingGrade(score) {
    const grade = getGrade(score);
    return grade !== "F";
}

function studentMsg(scores, studentScore) {
    const average = getAverage(scores);
    const grade = getGrade(studentScore);
    const passed = hasPassingGrade(studentScore);
    const passMsg = passed ? "You passed the course." : "You failed the course.";
    return `Class average: ${average.toFixed(1)}. Your grade: ${grade}. ${passMsg}`;
}
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/133.0.0.0 Safari/537.36

Challenge Information:

Build a Gradebook App - Build a Gradebook App

There’s no need to round the average. It’s a coincidence that examples in tests have single decimal digit.

thanks alot it worked