Tell us what’s happening:
tried with some AI
but cannot able to solve 22th step
Your code so far
function getAverage(scores) {
let sum = 0;
for (let i = 0; i < scores.length; i++) {
sum += scores[i];
}
return sum / scores.length; // No rounding here
}
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"; // Simplified
}
function studentMsg(classScores, yourScore) {
const average = getAverage(classScores).toFixed(1); // Round to 1 decimal place
const grade = getGrade(yourScore);
const passed = hasPassingGrade(yourScore);
return `Class average: ${average}. Your grade: ${grade}. ${passed ? "You passed the course." : "You failed the course."}`;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App