Review JavaScript Fundamentals by Building a Gradebook App - Step 2

Tell us what’s happening:

even if the console outputs the correct result: A B F
it tells me:
// running tests
Your getGrade function should return “B” if the score is between 80 and 89.
Your getGrade function should return “D” if the score is between 60 and 69.
// tests completed
// console output
A
B
F

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 result;
if (score == 100){
    result = "A++";
  } else if (score > 90){
    result = "A";
  } else if (score > 80){
    result = "B";
  } else if (score > 70){
    result = "C";
  } else if (score > 60){
    result = "D";
  } else {
    result = "F";
  } 
  return result;
}

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

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 2

Hello @debvelop !
The problem you are experiencing is caused by the operator you used here

This will take numbers greater than 80. Every score above 80 will be catered for, but 80 itself won’t be. The same applies to the other score, anything above 60 will be catered for but 60 won’t be.

I think it’d be ideal if you used a greater than or equal to in both cases. That, 80 and any number greater than that will be catered for, same as 60 and any other greater than 60.

and here

thank u dude!
I solved the error by writing: (score >= N) instead of (score > N)

1 Like