Build a Gradebook App: Step 17

Hello,

My code is working but for some reason failing step 17 which gives the error:
Your hasPassingGrade function should return false if the grade is an “F”.

I’ve been through and debugged, and the function does return a false boolean. Am I missing something obvious?

let averageScore = 0; 
let grade = "";
let studentScore = 0; 

function getAverage (scoresArray){
  let score = 0; 
  let average = 0; 
  for (let i in scoresArray){
    score += scoresArray[i];
  }
average+= score/scoresArray.length;
return average; 
}

function getGrade (studentScore){
  if (studentScore === 100){
    return "A+";
  } else if(studentScore >= 90){
    return "A";
  } else if(studentScore >= 80){
    return "B";
  }else if (studentScore >= 70){
    return "C";
  } else if (studentScore >= 60){
    return "D";
  } else  {
    return "F";
  }
}

function hasPassingGrade (grade){
  if (grade === "F"){
    return false;
  } else {
    return true;
  }
}

function studentMsg (classScores, studentScore){
  let classAverage = getAverage(classScores); 
  let studentGrade = getGrade(studentScore);
  let passFail = hasPassingGrade(studentGrade);
  
  
  if (passFail  == true){

     return `Class average: ${classAverage}. Your grade: ${studentGrade}. You passed the course.`;
  } else {
    return `Class average: ${classAverage}. Your grade: ${studentGrade}. You failed the course.`;
  }
  
}

Hi there and welcome to our community!

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".

You’re not calling the getGrade function within your hasPassingGrade function.

Just to be clear. The reason why you have to use getGrade is because hasPassingGrade should (and will be by the test) passed a score, not a grade.

  1. 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.