Tell us what’s happening:
I can’t understand why function hasPassingGrade() returns true. (
Your code so far
let average = getAverage([5, 5, 5, 5]);
function getAverage(scores) {
let sum = 0;
for (const score of scores) {
sum += score;
}
return sum / scores.length
}
let grade = getGrade(59);
function getGrade(average) {
if(average >= 0 && average <= 59) {
return "F";
} else if(average >= 60 && average <= 69) {
return "D";
} else if (average >= 70 && average <= 79) {
return "C";
} else if (average >= 80 && average <= 89) {
return "B";
} else if (average >= 90 && average <= 99) {
return "A";
} else if (average === 100) {
return "A+";
} else {
return "Invalid"
}
}
function hasPassingGrade(grade) {
if(grade == "F") {
return false;
} else {
return true;
}
}
console.log(grade);
console.log(average);
console.log(hasPassingGrade());
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36
Challenge Information:
Build a Gradebook App - Build a Gradebook App
https://www.freecodecamp.org/learn/full-stack-developer/lab-gradebook-app/build-a-gradebook-app
dhess
July 16, 2025, 11:53am
2
You should have a function named hasPassingGrade that takes a score as a parameter
Is that the parameter you are passing in?
The hasPassingGrade function should use the getGrade function to get the letter grade
Are you doing that?
Did you pass a parameter to the function?
Ok. I am passing to the function hasPassingGrade parameter from grade virable. In console.log(hasPassingGrade(grade )); I have “false” as required. But I still get the message " 19. Your hasPassingGrade function should return false if the grade is an "F" ."
dhess
July 16, 2025, 12:07pm
4
Please read my post again carefully. You are not following the instructions given. First off, what should hasPassingGrade() take as a parameter based on the instructions?
hasPassingGrade() should take as a parameter the letter from getGrade function. Right?
dhess
July 16, 2025, 12:18pm
6
No, that’s not right. Again, please read carefully what I posted. The first two quotes are taken directly from the instructions for this project. What does the very first quote say this function should take as a parameter?
I understand. Thank you for your help. Sorry, I am not native English speaker.
dhess
July 16, 2025, 12:21pm
8
That’s okay. Can you now say what that parameter should be?
It’s not a letter. This is the average score.
dhess
July 16, 2025, 12:24pm
10
Not the average score of the entire class, no. It should be the student’s score.
Then what should you use inside the function to get the student’s letter grade from the student’s score?
I do it! Can you rate my code?
removed by mod
If it passes the test A+.
There isn’t that much room for variation here due to the test requirements.
Please do not post solution code to the forum.
I understood. I am sorry.