My code won’t pass because hasPassingGrade() is not returning false.
I’ve console logged the hasPassingGrade function and it does in fact return false. Thank you for any help
- Your hasPassingGrade function should return false if the grade is an “F”.
Your code so far
const getAverage = (arr) => {
let totalMarks = 0
let averageMark = 0;
for(let item of arr){
totalMarks = totalMarks + item;
}
if(arr!==""){
averageMark = totalMarks/arr.length;
return averageMark;
}
}
const getGrade = (score) => {
const gradeRules = {
"A+": [100, 100],
"A": [90, 99],
"B": [80, 89],
"C":[70, 79],
"D":[60, 69],
"F":[0, 59]
};
for(let grade in gradeRules){
const [min, max] = gradeRules[grade];
if(score >= min && score <= max){
return grade;
};
}
}
const hasPassingGrade = (gradeScore) => {
return gradeScore !== "F";
}
const studentMsg = (arr, score) => {
return `Class average: ${getAverage(arr)}. Your grade: ${getGrade(score)}. You ${hasPassingGrade(getGrade(score)) === true ? "passed":"failed"} the course.`
}
console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App