Build a Gradebook App - Build a Gradebook App

Tell us what’s happening:

No matter what I do step 22 is wrong, can someone give me the solution.

Your code so far

function getAverage(scores) {
  let total = 0;
  for (let i = 0; i < scores.length; i++) {
    total += scores[i];
  }
  return Number((total / scores.length).toFixed(1));
}

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

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

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

Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Nope, we cannot give the solution - that’s against the forum rules.

Can you say how you’re stuck on this problem? Then we can help you get unstuck.

Step 22 is always wrong but idk how to get it working

Can you be more specific? What do the tests say is wrong? What have you tried to fix that?

it keeps replying with 22. Your

studentMsg

function should return the correct message based on the student’s score and the class average.

Ok. Have you tried seeing what your function returns if you call it and how it matches the requirements?

don’t worry I’ll just try whatever I can to get it right and I can’t then who cares I can just sit here being annoyed and give up

I’d be happy to help you. I just cannot write the answer for you, so we have to work towards fixing the code.

The very first thing to try to fix this is to run the function and compare the output to what the instructions ask for. That’s really the only reliable way I know to find and fix an error like this.

I’ve been doing this for 3 hours and I’ve given up, who cares I will skip it and pretend like I got it correct cos Step 22 kept being wrong

I would take a break. Being frustrated sucks and you’ve been at this for a while. But I would come back to this. The majority of effort in coding is working through being stuck in situations exactly like this so it’s important to work through this sort of thing when learning.

I’m just gonna blame the website that it doesn’t want me to pass so I’m taking this as I completed it don’t care

The website really does not have feelings. It honestly is just checking your output against the instructions.

I would like to see you pass the step. I would take a break and come back to this later. Like I said, this is a big part of what programming is - working through being stuck.

Tell us what’s happening:

Spent 3 hours on this one step which isn’t getting completed, Step 22 is so impossible to get correct, can someone provide me with the answer. I already gave up and almost stressed out from being stuck on this 1 step and it’s annoying me that I can’t get it correct so can someone help me and explain why I can’t get it correct

Your code so far

function getAverage(scores) {
  let total = 0;
  for (let score of scores) {
    total += score;
  }
  return Number((total / scores.length).toFixed(1));
}

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

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

function studentMsg(scores, score) {
  const avg = getAverage(scores); // already rounded and is a number
  const grade = getGrade(score);
  const passed = hasPassingGrade(score);
  return `Class average: ${avg}. Your grade: ${grade}. You ${passed ? "passed" : "failed"} the course.`;
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
// Class average: 71.7. Your grade: F. You failed the course.

console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
// Class average: 50.8. Your grade: A+. You passed the course.

Your browser information:

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

Challenge Information:

Build a Gradebook App - Build a Gradebook App

This is good to see.

The comment on this line confused me though. Where do the instructions ask for this rounding?