Build a Gradebook App - Lab

Hello there.
I’m stuck with this lab challenge : Build a Gradebook App

Everything works except Test n°19 : Your hasPassingGrade function should return false if the grade is an "F" .
I cannot find why it’s marked as wrong since it seems it works just fine.
I would appreciate a bit of help.

Here is my code:

const getAverage = testGrades => {
  let sumGrades = 0;
  for (const grade of testGrades) {
    sumGrades += grade;
  }
  return sumGrades / testGrades.length;
}

// console.log(getAverage([1,3,2,2,3,3]));

const getGrade = score => {
  let grade;
  if (score >= 0 && score <= 59) {
    grade = "F";
  } else if (score <= 69) {
    grade = "D";
  } else if (score <=79) {
    grade = "C";
  } else if (score <=89) {
    grade = "B";
  } else if (score <=99) {
    grade = "A";
  } else if (score === 100){
    grade = "A+";
  }
  return grade;
}

// console.log(getGrade(-101));

function hasPassingGrade(functionGetGrade) {
  return functionGetGrade!=="F";
}

console.log(hasPassingGrade(getGrade(60)));
console.log(hasPassingGrade(getGrade(59)));
console.log(hasPassingGrade(getGrade(0)));
console.log(hasPassingGrade(getGrade(10)));
console.log(hasPassingGrade(getGrade(20)));

function studentMsg(testGrades, score) {
  if (hasPassingGrade(getGrade(score))) {
    return `Class average: ${getAverage(testGrades)}. Your grade: ${getGrade(score)}. You passed the course.`;
  } else {
    return `Class average: ${getAverage(testGrades)}. Your grade: ${getGrade(score)}. You failed the course.`;
  }
}

//console.log(hasPassingGrade(getGrade(60)));
//console.log(studentMsg([100,90,95], 98));

Can you explain how this function is intended to work?

This function is intended to use the getGrade function as the argument.
If the return value of getGrade is “F”, then hasPassingGrade returns false. In any other case, hasPassingGrade returns true.

Why is the parameter functionGetGrade?

You should have a function named hasPassingGrade that takes a score as a parameter and returns either true or false depending on if the score corresponds to a passing grade.

The hasPassingGrade function should use the getGrade function to get the letter grade, and use it to determine if the grade is passing. A passing grade is anything different from "F".

It is said to use the getGrade function to convert the numeric grade into a letter. For me, it is logical then to directly pass this function as a parameter for the boolean function hasPassingGrade in order to make the code lighter and easier to read.

Otherwise, one could also pass the score as parameter of hasPassingGrade and then use getGrade function inside the hasPassingGrade function to convert into a letter. But I think doing this makes the code unnecessarily more complex. What do you think ?

I would try for correctness before trying to remove code to be “lighter and easier to read”. Fewer lines is rarely a good goal.

You need to have this parameter. You cannot have a different parameter.

Your hasPassingGrade function itself is not using getGrade.