Missing code in - Review JS Fundamentals by Building a Gradebook App - Step 4

Hello,

I just finished this project after a little trouble. I could have sworn my code was right but I kept getting an error message. The message read:

’ Your function call of 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.”.’

That’s when I realised that this ‘studentMsg’ line of code was missing from the pre-given console.log code for that task. I wasn’t asked to add this code in myself. I reset the code to make sure I didn’t accidentally delete it but it was still not appearing. After adding it in the code worked.

Thought this might be worth looking into for people potentially getting stuck on this step for this reason.

Hi there,

I didn’t find any missing code when I completed this project. I think you may have misunderstood the error message?

The best thing to do is copy your solution somewhere else, reset the code and then try to complete the function only (the code that goes in the studentMsg function) You should not need anything else.

Also pls post the code you are currently using in your reply so things can be clarified further.

I had the same problem. I just read this post and finally completed the gradebook app, but the line of code wasn’t there for me either.

I just watched a YouTube video of someone doing this project, and for him the line of code still wasn’t there, but the system still passed him anyways, so this may be the reason you passed without any problems.

My point was that there is no missing code. The message is trying to say there is a problem but it is not saying that code is missing. The tests that fCC run are not part of the code that we see.

But then why was there the same error code for me and Scott-Cockle that was solved when we added the line of code? Doesn’t that mean that the missing line was the problem?

I haven’t been able to recreate a missing line of code on my end. If you ever see the reset not return the code to its initial state, please try and let us know in the moment.

So for me, when I check my code without anything being done, the error code is 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.”

And then after I do all the steps to fix this, the error message shifts to
Your function call of 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.”

So therefore, if you check line 34 in the grade book step 4, you should be able to see studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37), but not studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100) on line 35. The second line of code is what I think needs to be added to fix this bug.

Can you post the code here before the second message shows up?

function studentMsg(totalScores, studentScore) {

}

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

This is the code without anything done.

yes, then you said you added some code and removed some code? So what was added and what was removed?

For me, I didn’t remove anything, but I added studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100) on the line after the other studentMsg to fix the bug.

Please post the code you are using for your function. It’s impossible to fully reproduce what you see without all of your code.

You should not need to make the function call yourself. It’s more likely that you have a small bug in your code.

function 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(studentScore) + ". " + passFail;
}
console.log(studentMsg([92, 88, 12, 77, 57, 100, 67, 38, 97, 89], 37));

This is the code I used before, and for some reason, the system passed me when I just tried it now unlike when it didn’t a day ago without the second missing line of code.

okay, no worries, thanks for sending it. Let us know if you run into anything like this again (hopefully you let us know when it happens so we can try to recreate)

1 Like

just completed the test, and had the same issue basically when the test is loading in you are missing the last console.log(studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100)) which is not being populated by the test - that is missing and it fails you on the test unless you manually add the console.log yourself.

I’ve never seen this issue.

Are you sure that when you click reset the startup code is missing?

Here’s what i see in the startup code:


function studentMsg(totalScores, studentScore) {

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

If you know what to do to make the test fail after that please let us know your steps with the code you used.

No yeah thats exactly same window i see too when i reset the code, but if you write your answer and if you will not include the second console.log in there it will fail

I am not able to recreate the issue.

Can you show me what answer you wrote? I need the full code so I can try to see what you see.