Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

I’m getting an error that says my function call should return “Class average: 71.7. Your grade: F. You failed the course.” I’m sure it’s something really small that I’m missing. Everything tends to blur if I stare at something long enough.

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) {
	const average = getAverage(totalScores);
	const grade = getGrade(average);
	if(grade == "F") {
		return "Class average: " + average + "Your grade: " + grade + "You failed the course. ";
	}
	else{
		return "Class average: " + average + "Your grade: " + grade + "You passed the course. ";
	}
}

// User Editable Region


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Welcome to the forum @rebazatz

Try console logging the function call to see the output.

Happy coding

This is what I saw after console logging.

Console log one of the function calls, that way you can see what your function is returning.

I understand that part. It’s just not returning the correct statement.

I got it figured out!

1 Like

by the message [Function: studentMsg] you are logging the function without calling it