Tell us what’s happening:
I got this error:
19. Your hasPassingGrade function should return false if the grade is an “F”.
…however, when I check the function is correct, don´t know exactly what is the issue.
Your code so far
function getAverage(arr) {
// return average score from arr
let result = 0;
for (let i=0; i < arr.length; i++){
result += arr[i];
}
return result / arr.length;
}
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(grade) {
if (grade == "F") {
return false;
} else {
return true;
}
}
console.log(hasPassingGrade("F"))
function studentMsg(arr, studentScore) {
let averagescore = getAverage(arr)
let stuScore = getGrade(studentScore)
let stuPass = hasPassingGrade(stuScore)
if (stuPass == true ) {
return `Class average: ${averagescore}. Your grade: ${stuScore}. You passed the course.`
} else {
return `Class average: ${averagescore}. Your grade: ${stuScore}. You failed the course.`
}
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37))
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