Build a Gradebook App - step 17

Im stuck on test 17.
here is the task -

  1. You should have a function named getAverage that takes an array of test scores as a parameter and returns the average score.
  2. You should have a function named getGrade that takes a student score as a parameter and returns a string representing a letter grade based on the score. Here are the scores and their corresponding letter grades:
Score Range Grade
100 "A+"
90 - 99 "A"
80 - 89 "B"
70 - 79 "C"
60 - 69 "D"
0 - 59 "F"
  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.
  2. 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".
  3. You should have a function named studentMsg that takes an array of scores and a student score as the parameters. The function should return a string with the format:
  • "Class average: average-goes-here. Your grade: grade-goes-here. You passed the course.", if the student passed the course.
  • "Class average: average-goes-here. Your grade: grade-goes-here. You failed the course.", if the student failed the course.Replace average-goes-here with the average of total scores and grade-goes-here with the student’s grade. Use getAverage to get the average score and getGrade to get the student’s grade.

tests -

    1. You should have a function named getAverage.
  • Passed:2. Your getAverage function should return a number.

  • Passed:3. getAverage([92, 88, 12, 77, 57, 100, 67, 38, 97, 89]) should return 71.7.

  • Passed:4. getAverage([45, 87, 98, 100, 86, 94, 67, 88, 94, 95]) should return 85.4.

  • Passed:5. getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]) should return 92.4.

  • Passed:6. Your getAverage function should return the average score of the test scores.

  • Passed:7. You should have a function named getGrade.

  • Passed:8. Your getGrade function should return "A+" if the score is 100.

  • Passed:9. Your getGrade function should return "A" if the score is between 90 and 99.

  • Passed:10. Your getGrade function should return "B" if the score is between 80 and 89.

  • Passed:11. Your getGrade function should return "C" if the score is between 70 and 79.

  • Passed:12. Your getGrade function should return "D" if the score is between 60 and 69.

  • Passed:13. Your getGrade function should return "F" if the score is between 0 and 59.

  • Passed:14. You should have a function named hasPassingGrade.

  • Passed:15. Your hasPassingGrade function should return a boolean value.

  • Passed:16. Your hasPassingGrade function should return true if the grade is an "A".

  • Failed:17. Your hasPassingGrade function should return false if the grade is an "F".

  • Passed:18. Your hasPassingGrade function should return true for all passing grades.

  • Passed:19. You should have a function named studentMsg.

  • Passed:20. studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37) should return the following message: "Class average: 71.7. Your grade: F. You failed the course.".

  • Passed:21. studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100) should return the following message: "Class average: 50.8. Your grade: A+. You passed the course.".

  • Passed:22. Your studentMsg function should return the correct message based on the student’s score and the class average.

const testArr = [92, 88, 12, 77, 57, 100, 67, 38, 97, 89],
      testArr2 = [45, 87, 98, 100, 86, 94, 67, 88, 94, 95];

function getAverage(testArr) {
 if (testArr.length > 0) {
   let sum = 0;
   for (let i = 0; i < testArr.length; i++) {
     sum += testArr[i]
   }
  const average = sum / testArr.length;
  return average;
 }
}

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

function hasPassingGrade(testScore) {
  let failing = "F"
  if (testScore !== failing) {
    return true;
  } else {
    return false;
  }
}

function studentMsg(testArr, studScore) {
  let classAverage = getAverage(testArr),
      studGrade = getGrade(studScore),
      hasPassed = hasPassingGrade(studGrade);
  if (hasPassed === true) {
    return `Class average: ${classAverage}. Your grade: ${studGrade}. You passed the course.`;
  } else {
    return `Class average: ${classAverage}. Your grade: ${studGrade}. You failed the course.`;
  }
}

console.log(studentMsg(testArr, 15));

Please talk about how you are stuck debugging instead of only posting the instructions, a list of failing tests, and your code. Thanks

I wouldnt be in the forum if I couldn’t figure it out with ai. The four tests related to hasPassingGrade with a correct output and 3/4 working doesnt make sense and i can only see it as a server side issue or with the way the compiler reads the code. If i knew what my issue was here i wouldnt be in the forum. As you can see the code is used in later functions and correctly returns the neccassary information for EVERY OTHER TEST TO BE PASSED.
So I would like someone to explain to me what my issue is. i can figure out a solution for an issue I can understand but i currently dont understand the issue thats why i provided the test and tasks as relative information for help

you will want to check your implementation of this function. If it receives a score, can you compare a score with a grade?

re read user stories 3 and 4

We cannot fix your code for you. That is against the rules.

Lets look at one specific test

How have you investigated this issue? What have you tried?