Need help on Code Challenges: JavaScript Fundamentals

Hello everyone. I hope you all are happy coding. I was doing the Code Challenges: JavaScript Fundamentals and I stumble into a problem. I did the code correctly but it’s not allowing me to pass and whenever I try to call the function it’s not working with the console.log().
Here is the link so you all better understand what I mean.

Can you post the code for your answer here? (we can’t see whether you got the correct answer or not from the link).

If it’s truly correct. Try saving the code and reloading the page.

Okay I will try to do that right now.

Take another look at the block of your else statement starting line 5. I think the way you are going about creating the average variable may be what’s causing you issues. And think about what you need as a return.

1 Like

What do you mean by the way I am going about creating the average variable. So maybe I could have the average equal a number instead and then put all the data contained in the average in another variable.

Your variable named “average” is written out twice. Inside the else block and then and then on the next line outside of the block but still within the overall function. You need to define it in the else block only.

Oh my gosh I never thought of it like that. I get what you mean by defining it. I also had to set it to a variable so when I put in the else it wouldn’t give me an error saying not defined. I will try to put the let outside of the function.

That’s not quite the direction I was trying to send you. In some cases we can define a variable outside a function but in this one we can’t. The variable uses some of the arguments of the function, the 3 different scores. It needs to be inside the function to access them.

I would delete your code on line 9.

Then add “let” to the start of your code on line 6 so you are actually defining/creating the average variable inside the else block.

I have never meet a code so smart like you. I mean how can you tell what as wrong and how exactly to fix it. I mean that’s amazing. I can become like this too. I just have to work hard and do more JavaScript so I can become use to it right.

Thank you but I am still very early into my coding journey. I am in the web path too, only a bit further along than you. Just trying to put something back into the community and problem solving other people’s code is another good way for me to learn.

You’ll get the hang of it, keep going!


Hey it worked. I know what you mean now. I put it in the else statement. The only problem now is that it’s not letting me pass and I did everything correct. I will have to check to see what I did wrong. Thank you for helping.

1 Like