Hello. I somehow deleted my resultDiv variable in my game and can’t reference it anymore, apparently. I don’t know where I deleted it from so I’m looking for a fresh pair of eyes on this. Forgive me I’m not that good at de bugging my code yet.
Here is my updated/current game w/ the reference error. https://replit.com/@DanielPetroski/Rock-Paper-and-Scissors#script.js
Thank you.
We recommend familiarising yourself with how to ask a question on this forum. Specifically, you are more likely to get useful help, if you provide a helpful title and description:
Open the console and look at the error it has a line number. Go to that line in the code and find the variable. It is inside a function, does that function have access to the variable in its own scope or an outer scope?
You even have some comments inside that function.
// You should do result.innerText = 'You Lose!'
// Don't forget to grab the div with the 'result' id!
This is how you use it inside the endGame function.
After you fix that you have the same error with handsDiv and playerScoreDiv.
I would suggest you grab the DOM elements one time at the start of the code and just use the top-level variables throughout the code. There is really no reason to keep querying the DOM for the same elements.
I edited your post. Replit links get embedded and it fails (for whatever reason) so we don’t see the link at all. Try posting the Replit links inside code blocks so that doesn’t happen.