Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Tell us what’s happening:

the code works but i don’t know why its not acceptable . i can’t understand the console message too

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)){
  return "Class averge: " + getAverage(totalScores) + ". Your grade:" + getGrade(studentScore) + ". You Passed the course.";
}else{
  return "Class averge: " + getAverage(totalScores) + ". Your grade: " + getGrade(studentScore) + ". 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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

Welcome to the forum :wave:

What is the message?

thank you!
here is the console message
// running tests 1.

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. // tests completed // console output Class averge: 71.7. Your grade: F. You Failed the course.

it shows as there is another studentMsg

this comes from your function

the requirement is

do you see the difference?

thank u for answering
yeah i got ur point and i fix it but still didn’t work
this is my console output right now
“Class average: 71.7. Your grade: F. You failed the course.”

Check the spacing here.

i did but unfortunately still not working

Please post your updated code.

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

1 Like