Review JavaScript Fundamentals by Building a Gradebook App - Step 3

Tell us what’s happening:

I am not sure why this is not working i have followed the instructions so far

Your code so far

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";
  }
}


// User Editable Region

function hasPassingGrade(score) {
   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) {
  const grade = getGrade(score);
  return grade !== 'F';
  hasPassingGrade="false"
}


console.log(hasPassingGrade(100));
console.log(hasPassingGrade(53));
console.log(hasPassingGrade(87));

// 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 3

Why have you defined two separate functions here (both of which have the same name)?

Your getGrade function already returns a grade based on the student’s score, so you don’t need to do this work again in the hasPassingGrade function.

All that you need to do in hasPassingGrade is check whether or not the grade returned by getGrade is ‘F’. As ‘F’ is the only failing grade, you should return false if the grade is ‘F’ and true if it is any other value. Your second hasPassingGrade function is actually fine, except that you don’t need the final line of code, as you are already returning a true or false value in the line above it.

function hasPassingGrade(score) {
   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) {
  const grade = getGrade(score);
}
console.log(hasPassingGrade(100));
console.log(hasPassingGrade(53));
console.log(hasPassingGrade(87));

You have the same problem as before…

unction hasPassingGrade(score) {
   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';
}



console.log(hasPassingGrade(100));
console.log(hasPassingGrade(53));
console.log(hasPassingGrade(87));

Why do you have this? This logic is already handled in the getGrade function. Your hasPassingGrade function should return only true or false, depending on the grade returned by getGrade.