Tell us what’s happening:
Hi there, step 19 is not passing, I have tried a bunch of things, I asked AI’s and still not passing, is there something else I should do? I would appreciate some guidance here, thanks!
Your code so far
function getAverage(arrayTest) {
if (arrayTest.length === 0) return 0;
let result = 0;
for (let i = 0; i < arrayTest.length; i++) {
result += arrayTest[i];
}
const average = result / arrayTest.length;
return average;
}
function getGrade(score) {
if (score === 100) {
return "A+";
} else if (score >= 90 && score <= 99) {
return "A";
} else if (score >= 80 && score <= 89) {
return "B";
} else if (score >= 70 && score <= 79) {
return "C";
} else if (score >= 60 && score <= 69) {
return "D";
} else {
return "F";
}
}
function hasPassingGrade(grade) {
return grade !== "F";
}
console.log(hasPassingGrade(getGrade(59)))
function studentMsg(classScores, studentNumericScore) {
const averageScore = getAverage(classScores);
const studentGrade = getGrade(studentNumericScore);
const passed = hasPassingGrade(studentGrade);
if (passed) {
return `Class average: ${averageScore}. Your grade: ${studentGrade}. You passed the course.`;
} else {
return `Class average: ${averageScore}. Your grade: ${studentGrade}. 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/140.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App