Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

Hi there, step 19 is not passing, I have tried a bunch of things, I asked AI’s and still not passing, is there something else I should do? I would appreciate some guidance here, thanks!

Your code so far

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

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 {
    return "F";
  }
}


function hasPassingGrade(grade) {
  return grade !== "F";
}
console.log(hasPassingGrade(getGrade(59)))

function studentMsg(classScores, studentNumericScore) {
  const averageScore = getAverage(classScores);
  const studentGrade = getGrade(studentNumericScore);
  const passed = hasPassingGrade(studentGrade); 

  if (passed) {
    return `Class average: ${averageScore}. Your grade: ${studentGrade}. You passed the course.`;
  } else {
    return `Class average: ${averageScore}. Your grade: ${studentGrade}. You failed the course.`;
  }
}

Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Unfortunately, LLMs (AI) have no way of knowing what is actually correct or not in your code.

This is your problem. What does the instructions say is the input to this function?

Hi, it should be the grade, right? [“A+”, “A”, “B“, “C“, “D”, “F“] , and I tested it and it does return false when the grade is “F”

I would read the instructions again, very carefully.

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

thank you so much! that really helped

1 Like