Tell us what’s happening:
I got all the functions working and I’m getting the correct output for each example, but I am not passing the last five steps of the project. Would someone take a look and give me some guidance please?
Your code so far
const student = ("");
function getAverage(scores) {
const initialValue = 0;
const sumWithInitial = scores.reduce(
(accumulator, currentValue) => accumulator + currentValue,
initialValue,
);
return sumWithInitial/scores.length;
}
getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]);
function getGrade(score) {
let grade = "";
if (score === 100) {
return grade = "A+";
} else if (score >= 90) {
return grade = "A";
} else if (score >= 80) {
return grade = "B";
} else if (score >= 70) {
return grade = "C";
} else if (score >= 60) {
return grade = "D";
} else if (score < 60) {
return grade = "F";}
}
getGrade(100);
function hasPassingGrade(grade) {
if (getGrade(grade) === "F") {
return false;
} else {
return true;
}
}
function studentMsg(scores, grade) {
getAverage(scores);
if (hasPassingGrade(grade)) {
return console.log("Class average: "+ getAverage(scores) +". Your grade: "+ getGrade(grade)+". You passed the course.")
} else if (!hasPassingGrade(grade)) {
return console.log("Class average: "+ getAverage(scores)+". Your grade: "+getGrade(grade)+". You failed the course.")
}
}
studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 76)
studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100)
studentMsg([12, 22, 32, 42, 52, 62, 72, 92], 85)
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/143.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App