Gradebook Project

function getAverage(scores) {
if (scores.length === 0) return 0;
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) {
return getGrade(score) !== “F”;
}

function studentMsg(scoresArray, studentScore) {
const average = getAverage(scoresArray);
const averageRounded = parseFloat(average.toFixed(1));
const grade = getGrade(studentScore);
if (hasPassingGrade(studentScore)) {
return Class average: ${averageRounded}. Your grade: ${grade}. You passed the course.
} else {
return Class average: ${averageRounded}. Your grade: ${grade}. You failed the course.
}
}

console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Get Help > Ask for Help button located on the challenge.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.