Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

The first one worked but the other showed up as undefined, please help me.

P.S. the full stops aren’t showing up either.

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) {
  let num = getAverage(totalScores);
  let avg = getGrade(studentScore);
  if (avg !== "F") {
    console.log ("Class average: " + num + "." + " Your grade: " + avg + " You passed the course.")
  } else {
    console.log ("Class average: " + num + "." + " Your grade: " + avg + " 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

console.log doesn’t return anything from your function

I tried that. It didn’t work. And the full stops are STILL missing!
BTW here is my code so far:

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

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 do you mean by “the full stops are STILL missing”? What full stop do you believe you added to the string but do not see in the output from the function?

The one that was meant to be after the grading.

Ok, where in your code is that full stop?

After the avg variable.

Here? I don’t see a full stop.

your console log satement should read as provided. I.e use the word average not avg.

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.

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.