Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

i am still unable to clear the error despite getting an output

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(studentScore) == true) {
    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.");
  }
}

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

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Hi @Maryam1004

SyntaxError: unknown: Unexpected token (40:0)

  38 | }
  39 |
> 40 |
     | ^

The console is giving you some information.
It looks like the function is not properly closed.

Happy coding

I have closed it but im still receiving error messages

Did you close the second to last function?

yes i did but im still having errors

Please post your full code.

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";
function studentMsg(totalScores, studentScore) {
  if (hasPassingGrade(studentScore) == true) {
    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.");
  }
  }
}

Great job on progressing to Step 4! It’s exciting to see how you’re applying JavaScript fundamentals by building a Gradebook app. Keep up the awesome work—each step brings you closer to mastering these key concepts. Looking forward to seeing how your app evolves!

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

What errors?

Be sure and read more than just the first line of the failing message. The ability to read and comprehend error messages is a skill you’ll need to acquire as a developer. Ask questions on what you don’t understand.

studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37)

should return the following message:

"Class average: 71.7. Your grade: F. You failed the course."

. 2.

studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100)

should return the following message:

"Class average: 50.8. Your grade: A++. You passed the course."

. 3. Your

studentMsg

function should return the correct message based on the student’s score and the class average.

And what does your function return when you test this? Compare your result with the given result and see what’s different.

Hi @Maryam1004

ReferenceError: studentMsg is not defined

The console log is calling studentMsg, however it is not defined due to the syntax errors.

Have a go at debugging why studentMsg is not defined.

Happy coding

Your code is missing " } ". Here’s the working code. Happy coding!
–removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

2nd warning about this: please do not share solution code to the forum, thanks