Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

Hello,
Please in my opinion i thought i have inputed the correct syntax but it wont let me pass.
Can someone help me out please?

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 sum = 0;
 
  for(const score of totalScores){
   
  sum += score;

}
  

 let result = ""   
 result += "Class average: 71.7."+" Your grade: F."+" You failed the course."

return result

 
}
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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Why are you hardcoding the results. Don’t you want them to be based on what you calculate in the function?

Hi, your function is not really doing anything. You are just writing the result yourself, and returning it. You shouldn’t calculate the average or the grade yourself. The function should be doing it for you, using the two functions you already have for that. Then you should create a condition to see if the student passed or not and concatenate those values and the message to the string. It should work for other cases as well, not only the one inside the console.log. I think you need to try a bit more, before we can help you any further. But dont give up, you can do it

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.