Tell us what’s happening:
I do some console test with different numbers and work fine, but the point 17. and 22. dont pass and i dont know why
- Your hasPassingGrade function should return false if the grade is an
“F”
. 22. Your studentMsg function should return the correct message based on the student’s score and the class average.
Your code so far
function getAverage (testScores) {
let average = 0;
for(let char of testScores) {
average += char;
}
return average / testScores.length;
}
function getGrade (score) {
if(score <= 59) {
return "F";
} else if(score <= 69) {
return "D";
} else if(score <= 79) {
return "C";
} else if(score <= 89) {
return "B";
} else if(score <= 99) {
return "A";
} else {
return "A+";
}
}
function hasPassingGrade (grade) {
return grade !== "F"
}
function studentMsg(testScores, studentScore) {
let average = getAverage(testScores);
let grade = getGrade(studentScore);
if (hasPassingGrade(grade)) {
return `Class average: ${average.toFixed(1)}. Your grade: ${grade}. You passed the course.`;
} else {
return `Class average: ${average.toFixed(1)}. Your grade: ${grade}. You failed the course.`;
}
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
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/135.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App