Can't trell what is wrong with the code

function studentMsg(totalScores, studentScore) {

     if (studentScore <= 59){
        return "Class Average:" 
+ getAverage(totalScores) + ". Your Grade: " + 
getGrade(studentScore)+ ". You failed the course.";
 } else if (studentScore > 59) {

      return "Class Average: " + getAverage(totalScores) +
 ". Your Grade: " + getGrade(studentScore) +". You passed the course.";

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

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

Hi @emnet

So the forum can assist please post your full code.

Use the following method to post code to the forum:

  1. On a separate line type three back ticks.
  2. On a separate line paste your code.
  3. On the last line type three back ticks. Here is a single back tick `

Happy coding

Happy coding

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 (studentScore <= 59){
       return "Class Average:" 
+ getAverage(totalScores) + ". Your Grade: " + 
getGrade(studentScore)+ ". You failed the course.";
} else if (studentScore > 59) {

     return "Class Average: " + getAverage(totalScores) +
". Your Grade: " + getGrade(studentScore) +". You passed the course.";

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

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

Hello,
first think to getAverage , getGrade and hasPassingGrade methode of your current code that will help you and don’t use if like that cause hasPassingGrade do the same thing .

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 (').

can you also share the link of the project you are doing?

In the future, if you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

thank you

let’s do some debugging

the first failed test is

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 if we add this:

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.");

we can see what is the actual output

this prints:

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

do you see the differences?