Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

I dont what is the mistake in my code i am getting error that Your studentMsg function should return the correct message based on the student’s score and the class average.

Your code so far

function getAverage(totalScores) {
    let sum = totalScores.reduce((acc, score) => acc + score, 0);
    return sum / totalScores.length;
}

function getGrade(studentScore) {
    if (studentScore === 100) {
        return "A++";
    } else if (studentScore >= 90) {
        return "A";
    } else if (studentScore >= 80) {
        return "B";
    } else if (studentScore >= 70) {
        return "C";

// User Editable Region

    } else if (studentScore >= 60) {
        return "D";
    } else {
        return "F";
    }
}

function studentMsg(totalScores, studentScore) {
    let average = getAverage(totalScores);
    let grade = getGrade(studentScore);
    let passOrFail = grade !== "F" ? "You passed the course." : "You failed the course.";
    let message = `Class average: ${average.toFixed(1)}. Your grade: ${grade}. ${passOrFail}`;
    return message;
}

// Test cases
console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100)); // Expected: "Class average: 50.8. Your grade: A++. You passed the course."
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37)); // Expected: "Class average: 71.7. Your grade: F. You failed the course."


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Hi there!
Remove toFixed() method from your code and you will pass the challenge.