Build a Gradebook App - Step 17

Tell us what’s happening:

I’m getting the correct output but I failing test 17, 20, 21, and 22.

Your code so far

function getAverage(array){
  
  let average = (array.reduce((acc, num) => acc + num, 0)) /array.length;
  console.log(average);
  return average;
};
getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]);

function getGrade(score){
  if(score === 100){
    return "A+";
  } else if(score>=90 && score<=99){
    return "A";
  }else if (score>=80 && score<=89){
    return "B";
  } else if (score>=70 && score<=79){
    return "C";
  } else if (score>=60 && score<=69){
    return "D";
  } else if (score>=0 && score<=59){
    return "F";
  } 
};

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


function studentMsg(scoreArray, studentScore) {
  if (getGrade(studentScore) !== "F") {
    return "Class average: " + getAverage(scoreArray) + ". " + "Your grade: " + getGrade(studentScore) +  ". " + " You passed the course.";} else{
    return "Class average: " + getAverage(scoreArray) + ". " + "Your grade: " + getGrade(studentScore) + ". " + " You failed the course.";
    } 
}



console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));

When i use this:

function hasPassingGrade(grade) {
return [“A+”, “A”, “B”, “C”, “D”].includes(grade);
}

16 and 18 fail. 17 passes/

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Hi there. You have added extra quote marks within both returning strings.

Hi. In addition to what @hasanzaib1389 says, for number 17 you need to look at your function again.

function hasPassingGrade(grade) {
return grade !== “F”;
}

What is this doing:

return grade !== "F";

1 Like

thank you. I was able to fix this issue.

1 Like

I’m sorry, I still can’t figure out what I am doing wrong.

I also used this code:

function hasPassingGrade(grade) {

return [“A+”, “A”, “B”, “C”, “D”].includes(grade);

}

but I’m failing 16 and 18.

You have a function getGrade() to get the passing grade and return it in your hasPassingGrade function.

1 Like

thank you so much for taking the time. this worked!

1 Like