Review JavaScript Fundamentals by Building a Gradebook App - Step 2

Tell us what’s happening:

Why doesn’t it pass? I don’t know what the problem is…

Your code so far

function getAverage(scores) {
  let sum = 0;

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

  return sum / scores.length;
}

// User Editable Region

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

  return letterGrade;
}


console.log(getGrade(96));
console.log(getGrade(82));
console.log(getGrade(56));


// 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/125.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 2

add a console.log(getGrade(100)), what does it print?

Your getGrade function should return "A++" if the score is 100

Nevermind, I fixed it on my own.

You have to add else if in the condition where you are checking for the grade >= 90. But you have use if statement. Use else if.

and what does it return? with the console log you can see it

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.