Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

function getAverage(scores) {
const total = scores.reduce((sum, score) => sum + score, 0);
return total / scores.length;
}

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 studentMsg(totalScores, studentScore) {
const average = getAverage(totalScores);
const grade = getGrade(studentScore);
const passed = studentScore >= aver

Your code so far


// User Editable Region

function getAverage(scores) {
  const total = scores.reduce((sum, score) => sum + score, 0);
  return total / scores.length;
}

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 studentMsg(totalScores, studentScore) {
  const average = getAverage(totalScores);
  const grade = getGrade(studentScore);
  const passed = studentScore >= average;

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

console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));


// User Editable Region

Your browser information:

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

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Welcome to the forum @kagamejr

Try removing the .toFixed() method.

Happy coding