Step 4 Review JavaScript Fundamentals by Building a Gradebook App

Hi guys, I can’t seem to pass this code, this there something I’m getting wrong ??

here’s my code

let passFail
  if (hasPassingGrade(studentScore)) {
    passFail = "You passed the course."
  } else {
    passFail = "You failed 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], 100));

I

please include a link to the step in your post.

1 Like

Thanks. Can you paste all the code here? (Copy all the way from the top of the editor to the bottom line)

I’m asking because the code you pasted above is missing the function definition.

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

Also make sure you use the correct capitalization. Here is should be Class not class

Now that the teacher has all of the information they need, they want to be able to message the student with the results.

Complete the studentMsg function with totalScores and studentScore for parameters. The function should return a string representing a message to the student.

If the student passed the course, the string should follow this format:

Example Code

Class average: average-goes-here. Your grade: grade-goes-here. You passed the course.

If the student failed the course, the string should follow this format:

Example Code

Class average: average-goes-here. Your grade: grade-goes-here. You failed the course.

Replace average-goes-here with the average of the total scores. Replace grade-goes-here with the student’s grade.

Tips

  • Use the getAverage function to get the class average.
  • Use the getGrade function to get the student’s grade.
  • Use string concatenation (+) to build the message.
  • Be careful with the punctuation and spaces in the message.
function studentMsg(totalScores, studentScore) {
   let courseResult = "You passed the course."
   if(!hasPassingGrade(studentScore)) {
       courseResult = "You failed the course."
}
   return "class average: " + getAverage(totalScores) + ".Your grade: " + getGrade(studentScore) + ". " + courseResult
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 40));
}

I just needed the code. You can place the code in a preformatted block so it is nicely readable in the forum.

You also need a space after the period here.

And you also need to delete the extra } here

Still not getting it, I have removed the extra } and added space on ".Your but still not going through

here’s the error I’m getting

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

Hi there!
Post you updated code, that we can assist you.

Hi, below is the updated code, but still not going through

function studentMsg(totalScores, studentScore) {
let courseResult = “You passed the course.”
if(!hasPassingGrade(studentScore)) {
courseResult = “You failed the course.”
}
return "class average: " + getAverage(totalScores) + ".Your grade: " + getGrade(studentScore) + ". " + courseResult
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 40));
}

Hi there!

Edit: You need to add the correct quote marks and add a space before Your grade: string. Also the first latter of Class average string should be capitalized.

Hi,

You haven’t fixed the mistakes I pointed out.

here’s the imagine, Capital added on Class average, and a space to ".Your

but its not going through

Make sure you have a semicolon after each statement (like the return).
If still not working, please copy the code here so we can test it.

edit:remove the last } bracket that have red underline.

it shouldn’t matter though? (The space between a string and the concatenation operator would not cause a step to fail unless there’s a bug in the test)

2 Likes

the code is passing without semicolon. when the bugs are removed

1 Like