Build A Gradebook App
function getAverage (scores) {
let average = 0;
for (const score of scores) {
average += score;
}
average = average / scores.length;
return average;
}
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 (score) {
if (getGrade(score) != "F") {
return true
} else {
return false
}
}
function studentMsg (scores, score) {
const average = getAverage(scores);
const grade = getGrade(score)
if (hasPassingGrade(grade)) {
return `Class average: ${average}. Your grade: ${grade}. You passed the course.`;
} else {
return `Class average: ${average}. Your grade: ${grade}. You failed the course.`
}
}
The get grade function isn’t returning any scores below A, and I’ve tried a few things but I haven’t found why.
Any help would be very helpful.
ILM
January 21, 2026, 4:46pm
2
Please post again your code following this guide to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
I have edited the original post.
ILM
January 21, 2026, 4:51pm
4
Xynerian:
score => 90
are you sure on this syntax? hint, that is not a comparison operator
Not anymore now that you said that.
That fixed that problem.
Is this right?
function hasPassingGrade (score) {
if (getGrade(score) != "F") {
return true
} else {
return false
}
}
ILM
January 21, 2026, 5:03pm
7
what issue are you having with it? does it do what it should do?
It’s returning false even though it’s getting passed “A+“
are u sure u r supposed to pass grade as an argument here?
I think so, am I not?
Even if not the grade function still needs to be fixed.
Xynerian:
hasPassingGrade (score)
please consider what your hasPassingGrade(score) function is expecting as a parameter
then consider what is stored in your grade variable when u pass it to hasPassingGrade(grade) in the next line