Review JavaScript Fundamentals by Building a Gradebook App - Step 3

Tell us what’s happening:

Hello,

I would need help on this :frowning:
I am asked to return false if the grade is F and true otherwise. This is what I am trying to do with my “if” and “else” but this is not correct.

Thanks in advance for any hint you can provide.

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) {
  let result;
  if (getGrade(score) === "F") {result = "false";} else {result = "true";}
return result;}

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/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 3

do you remember the difference between a boolean and a string?

Ah ok thanks I think I got it !
With boolean I don’t need to ask for the result right ? Just checking if the grade is F and it will automatically check if this is true or false ? It would then only use:

return getGrade(score) !== “F”;

Am I correct or do I miss anything ?

I meant the difference between true and "true" considering you wrote the second one

but what you wrote is also correct

Yes understood now many thanks. I tried both and they work (using boolean instead of “string” as well). I did forgot the difference :frowning:

Note - I would use conventional formatting instead of writing that if statement all on one line.