Tell us what’s happening:
not sure what’s happening in the last function if I console.log the tests i get the correct answers but not passing tests 23 onwards, any clue on where I need to look.
Your code so far
function getAverage(array) {
let sum = 0;
for (let i = 0; i < array.length; i++) {
sum += array[i];
}
return sum/array.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";
} else if (studentScore >= 60) {
return "D";
} else if (studentScore >= 0) {
return "F";
}
};
function hasPassingGrade(score) {
let studentGrade = getGrade(score);
if (studentGrade !== "F") {
return true;
} else {
return false;
}
};
function studentMsg(array, score) {
const average = getAverage(array);
const grade = getGrade(score);
if (grade !== "F") {
return `Class Average: ${average}. Your grade: ${grade}. You passed the course.`;
} else {
return `Class average: ${average}. Your grade: ${grade}. You failed the course.`;
}
};
console.log(studentMsg([15, 25, 35, 45, 55, 60, 70, 60], 75));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36 Edg/147.0.0.0
Challenge Information:
Build a Gradebook App - Build a Gradebook App