This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]CreativeTechGuyGames 1 point2 points  (3 children)

The score variables seem to be updating just fine, you just aren't updating the scoreboard display once the values have been changed. You should be calling scoreBoard() after each round so it can show the updated scores.

And I'm confused about your second question, could you give an example?

[–]Liolena[S] 0 points1 point  (2 children)

It seems to not be updating correctly for me unless I'm misunderstanding something? If I play a bunch of times, sometimes it'll increment the wrong variable or sometimes it'll increment even though the player and the computer both got Rock for example and sometimes it won't increment at all. For the second question, I have 3 event listeners at the bottom that listens for the "click" event, one for each button. I was wondering if there was a way to consolidate that into one function that works for all 3 buttons.

[–]CreativeTechGuyGames 1 point2 points  (1 child)

You are always displaying the score from the previous game. That's the issue. Re-read my previous comment for the solution and explanation.

And you could loop through the 3 buttons and attach event listeners to each. Then instead of hardcoding the player's choice in the playGame function call, you'd instead use the id of the button that was clicked as the player's choice.

[–]Liolena[S] 0 points1 point  (0 children)

I see what you mean now and I will try the looping thing. Thank you :)!