Build A Gradebook App

Build A Gradebook App

function getAverage (scores) {
  let average = 0;
  for (const score of scores) {
    average += score;
  }
  average = average / scores.length;
  return average;
}

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

function hasPassingGrade (score) {
  if (getGrade(score) != "F") {
    return true
  } else {
    return false
  }
}

function studentMsg (scores, score) {
  const average = getAverage(scores);
  const grade = getGrade(score)
  if (hasPassingGrade(grade)) {
    return `Class average: ${average}. Your grade: ${grade}. You passed the course.`;
  } else {
    return `Class average: ${average}. Your grade: ${grade}. You failed the course.`
  }
}

The get grade function isn’t returning any scores below A, and I’ve tried a few things but I haven’t found why.

Any help would be very helpful.

Please post again your code following this guide to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I have edited the original post.

are you sure on this syntax? hint, that is not a comparison operator

Not anymore now that you said that.

That fixed that problem.

Is this right?

function hasPassingGrade (score) {
  if (getGrade(score) != "F") {
    return true
  } else {
    return false
  }
}

what issue are you having with it? does it do what it should do?

It’s returning false even though it’s getting passed “A+“

are u sure u r supposed to pass grade as an argument here?

I think so, am I not?

Even if not the grade function still needs to be fixed.

please consider what your hasPassingGrade(score) function is expecting as a parameter

then consider what is stored in your grade variable when u pass it to hasPassingGrade(grade) in the next line