Building gradebook app part 4 help

Been stuck on part 4 for hours. checked on YouTube and used same code and it still keeps failing. can someone help me on this one plz.

We can help but please click on the help button to open a post here with the code and a link tot he challenge (it will be created for you with the button).

Please try it now.

(This is the code i used) I also dont see the help button you mentioned.

unction studentMsg(totalScores, studentScore) {
let passFail
if (hasPassingGrade(studentScore)) {
passFail = “You passed the course.”;
} else {
passFail = “You failed the course.”
}
return "Class average: " + getAverage(totalScores) + "Your grade: " + getGrade(studentScores) + " . "
+passFail;

Also used this code:

function studentMsg(totalScores, studentScore) {
const classAverage = getAverage(totalScores)
const studentGrade = getGrade(studentScore)

const passed = hasPassingGrade(studentScore)

let message = class average: ${classAverage}. Your grade: ${studentGrade}.
if(passed) {
message += ‘You passed the course.’
} else {
message += ‘You failed the course.’
}

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

and its giving me the correct output but still saying the code does not pass can someone plz help with this.

Tell us what’s happening:

Keeps failing me. Im not sure whats going on but it wont work.

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) {
 const classAverage = getAverage(totalScores)
 const studentGrade = getGrade(studentScore)

 const passed = hasPassingGrade(studentScore)

 let message = `class average: ${classAverage}. Your grade: ${studentGrade}. `
 if(passed) {
   message += 'You passed the course.'
 } else {
   message += 'You failed the course.'
 }

 return message
}
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/129.0.0.0 Safari/537.36 Edg/129.0.0.0

Challenge Information:

Review JavaScript Fundamentals by Building a Gradebook App - Step 4

the string has to match exactly
For example, it should start with a capital letter here

Look at the class in the return message, try with capital for the first letter, this result is case sensitive.

please don’t create duplicate posts for the same challenge or topic.
Just update your original post or respond to someone so that you can get more help without making a duplicate post on the forum.

I have merged your duplicates.

1 Like

sorry about that still learning how to use forum. Thanks!

1 Like

Tried it and still getting same result.

Don’t understand what your saying to do?

Please post the updated code in your reply if you need more help.

function studentMsg(totalScores, studentScore) {
  let passFail 
  if (hasPassingGrade(studentScore)) {
    passFail = "You passed the course."
  } else {
    passFail = "You fail the course."
  }
 return "Class average: " + getAverage(totalScores) + ". Your grade: " + getGrade
 (studentScore) + ". " + passFail;
}

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

is this the correct string? (fail or failed?)

please double check your work. The strings should match exactly.
Make use of console.log to help you check.

1 Like

Ok thanks! I finally got it. I don’t know why I was having so much trouble with this one step. Sorry for the inconvenience. I really appreciate your help and patience!

1 Like

we’re here to help. (But please do take our advice to heart when we say: check that the text is the same, pls take the time and make this effort)

1 Like