Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

I cannot seem to figure out why my “you passed the course” line is not working but my “you failed the course” line is… Can someone please point me in the right direction of what part of my code I should be looking to fix… please don’t give me the answer just where I am wrong please.

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

function hasPassingGrade(score) {
  return getGrade(score) !== "F";
}


// User Editable Region

function studentMsg(totalScores, studentScore) {
 if (hasPassingGrade(getGrade)) {
      return "Class average: " + getAverage(totalScores) + ". Your grade: " + getGrade(studentScore) + ". You passed the course.";
    } else {
      return "Class average: " + getAverage(totalScores) + ". Your grade: " + getGrade(studentScore) + ". You failed the course.";
    }
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

// User Editable Region


Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Hi @kmccas !

Welcome to the forum!

Your issue is here

remember that getGrade is a function.
what you are attempting to do is pass in a reference to that function.
But that is not correct.

hasPassingGrade accepts a score.
So you will need to update that if statement to pass in another argument instead of getGrade

once you fix that, then the test will pass

2 Likes

if(studentScore >= 60)
Am I on the right path by changing the whole if condition?
or closer like this??
if(wasPassingGrade(studentScore) >= 60)
I also tried the !== “F”
I really thought I understood what you said but i’m still not seeming to get it…
Thank you for helping me.

2 posts were split to a new topic: Stuck on step 4 of gradebook app

where is this function from?

you have hasPassingGrade, it outputs a boolean, not a number, so the >= 60 doesn’t make sense.

this can be a way, but you wrote the hasPassingGrade function to use it, so you could maybe use it