Tell us what’s happening:
I am passing all the checks other than test 17. I am getting the correct result out of the function but for some reason unbeknownst to me, the function doesn’t pass.
Maybe a small typo or what can it be?!
Your code so far
// Get in the array and return the average of sum
function getAverage (array) {
let result = 0;
for(let num of array) {
result += num;
}
return result / array.length;
}
// pass in the score and check what grade it is
function getGrade (int) {
if(int === 100) {
return "A+"
} else if(int >= 90) {
return "A"
} else if (int >= 80) {
return "B";
} else if (int >= 70) {
return "C";
} else if(int >= 60) {
return "D"
} else {
return "F"
}
}
// Checks if getGrade function result is a passing grade
function hasPassingGrade (score) {
return score !== "F" ? true : false;
}
// Show message to user if the grade is passable or not
function studentMsg (arrayScores, studentScore) {
let averageScore = getAverage(arrayScores);
let yourGrade = getGrade(studentScore);
let passingGrade = hasPassingGrade(yourGrade);
if(passingGrade) {
return `Class average: ${averageScore}. Your grade: ${yourGrade}. You passed the course.`;
} else {
return `Class average: ${averageScore}. Your grade: ${yourGrade}. You failed the course.`;
}
}
console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 60));
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App
Summary
This text will be hidden