Full Stack Curriculum - Build a Gradebook App

Tell us what’s happening:

My code is successfully executing but will still not pass this final requirement:

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

Your code so far

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

console.log(getAverage([38, 99, 87, 100, 100, 100, 100, 100, 100, 100]));

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) {
  return score >= 60;  // Simplified return statement
}

function studentMsg(scores, studentScore) {
  const average = getAverage(scores);
  const studentGrade = getGrade(studentScore);
  const passing = hasPassingGrade(studentScore);

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

console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37))

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36

Challenge Information:

Build a Gradebook App - Build a Gradebook App

Hi there. The test doesn’t want to round the average.

1 Like

I see, thank you. I guess I was just doing too much. Lol.

1 Like