Review-js-fundamentals-by-building-a-gradebook-app

function getAverage(scores) {
  let sum = 0;

  for (const score of scores) {
    sum += score;
  }

  return sum / scores.length;
}

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 getGrade(score) !== "F";
}

function studentMsg(totalScores, studentScore) {
      const avg = getAverage(totalScores);
      const grade = getGrade(studentScore);
      let passingTheCourse = "You passed the course.";
       if(! hasPassingGrade(studentScore)){
          passingTheCourse = " You failed the course.";
       }

      let msg ="Class average: " + avg + "." + " Your grade: " + grade + "." + " " + passingTheCourse;
      return '"' + msg + '"' + '.'; 
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37))
//console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));`Preformatted text`

what the problem here in my code ?!

what step are you doing?

anyway, you usually don’t put quotes in a string, you may want to remove those

1 Like