Step 4 - Problem in Review JavaScript Fundamentals in Gradebook App

function studentMsg(totalScores, studentScore) {
  let classAvg = getAverage(totalScores);
  let stuGrade = getGrade(studentScore);

  if (stuGrade !== "F") {
    return (
      "Class average: " +
      classAvg.toFixed(1) +
      ".Your grade: " +
      stuGrade +
      ".You passed the course."
    );
  } else {
    return (
      "Class average: " +
      classAvg.toFixed(1) +
      ". Your grade: " +
      stuGrade +
      ". You failed  the course."
    );
  }
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 89));

Please tell me why it is happening?
Error is occuring that:-

  1. Your function call of
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."
  1. Your function call of
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."
  1. Your
studentMsg

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

what is happening? can you give a link to the step?

This is the link.

what is happening? can you answer that please?

function studentMsg(totalScores, studentScore) {
let classAvg = getAverage(totalScores);
let stuGrade = getGrade(studentScore);

if(stuGrade !== "F"){
    return "Class average: " + classAvg + " .Your grade: " + stuGrade + ". You passed the course."
} else {
   return "Class average: " + classAvg + ". Your grade: " + stuGrade + ". You failed  the course."
}

}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

this is the code.
and the error is occuring.
Your

studentMsg

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

which code is the code you have issues with? you posted two different functions

both code I have issue . output is right but code is not submitting.

If the code is not submitting the output is not right

let’s look at this one:

The first failing test is:

Your function call of 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." .

So let’s debug it!
Let’s add:

console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));
console.log("Class average: 71.7. Your grade: F. You failed the course.");

This prints to the console:

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

There are some differences in spacing, those would need to be fixed.

Also let’s check the other test:

Your function call of 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.".

With this:

console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100));
console.log("Class average: 50.8. Your grade: A++. You passed the course.");

It gives:

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

There are some spacing issues here too

what will be the right solution of it.

return "Class average: " + classAvg + " .Your grade: " + stuGrade + ". You passed the course."

what I need to fix in it?

where are the differences in the two lines?

Can you see the differences here? I see one difference

difference is in first line of period.

Yes, that’s the difference. Change your line of code to put the period in the right palce!

return "Class average: " + classAvg + ". Your grade: " + stuGrade + ". You passed the course."

I fixed that issue but still code is not submitting.

if(stuGrade !== "F"){
    return "Class average: " + classAvg + ". Your grade: " + stuGrade + ". You passed the course."
} else {
   return "Class average: " + classAvg + ". Your grade: " + stuGrade + ". You failed  the course."
}

I fixed both lines of code but still same error is occuring.

I am checking again with this and still see a difference:

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

Right after failed

Thank you very much. I have fixed the issue.