Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Hi @iskren500

The hasPassingGrade function returns either True or False
It will never equal to "F", so the else statement will always run.

Happy coding

37 is equal to F. I don’t get it.

37 is true so it should return failed not passed

You didn’t need that comparison after hasPassingGrade(studentScore)

What should I put, < 60?

function studentMsg(totalScores, studentScore) {
if (hasPassingGrade(studentScore) < 60)  {
    return (`Class average: ${getAverage(totalScores)}. Your grade: ${getGrade(studentScore)}. You failed the course.`)
  } else {
   return (`Class average: ${getAverage(totalScores)}. Your grade: ${getGrade(studentScore)}. You passed the course.`)
  }
}

console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

You didn’t need to compare the hasPassingGrade(studentScore) to anything. Everything is calculated before in the previous functions.

now its saying you passed the test, when it should you failed

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

console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

Actually, you have add the failed statement in if block and the passed statement in else block. So you need to make the condition false by adding the negation operator before the if condition within the condition () braces.

Finally it worked, thanks alot for the help :slight_smile:

1 Like

Your most welcome. Keep coding. Happy Coding.