+ 1

Rock Paper Scissors game Help.

Iā€™m trying to make Rock Paper Scissors game, and before I go any further, I need help taking care of this problem. JS/ The go_btn is the button that says ā€˜ROCKā€™. This is how the game goes. You click ā€˜ROCKā€™, and then at the bottom the emojis say Paper Scissors Shoot (with rotating motion). On shoot you have to pick your weapon (the three emojis at the top). But the ā€˜ROCKā€™ button is causing problems. The more you click on it, the score keeps adding more than one (+1, +1, +2, +3...) Iā€™m not sure how to... https://code.sololearn.com/Wo4uSXbgnm5T/?ref=app

6th Jan 2020, 5:45 AM
Ginfio
Ginfio - avatar
10 Answers
+ 1
the reason is that your rock, paper, scissors add event listener in play() so when player clicked go_btn, it adds the event listener multiple times, so after say 3 clicks of go_btn, one click of paper will become playing paper for three times. solution is to take those three addEventListener out of play(), a good place is below go_btn addEventListener
6th Jan 2020, 9:56 AM
Gordon
Gordon - avatar
+ 1
default display none in play(), set style.display
6th Jan 2020, 11:57 PM
Gordon
Gordon - avatar
+ 1
use random syntax
8th Jan 2020, 4:26 AM
Sujal Uprety
Sujal Uprety - avatar
0
I didnā€™t finish my thought: Iā€™m not even sure how we would fix that. I feel like Iā€™m expecting too much.
6th Jan 2020, 5:46 AM
Ginfio
Ginfio - avatar
0
Gordon Yeah, I could pit it outside, but I want it to be like... You canā€™t press on the options (rock, paper, sciss..), befoe clicking the ā€˜ROCKā€™ button. have to click on ā€˜ROCKā€™ everytime before it you can click on the options (rock, paper, sc...)
6th Jan 2020, 6:14 PM
Ginfio
Ginfio - avatar
0
Gordon , display the buttons, none| block, when ā€˜ROCKā€™ clicked?
7th Jan 2020, 12:50 AM
Ginfio
Ginfio - avatar
0
yes, in css, display none in button event listener, set their style.display block (or other appropriate value)
7th Jan 2020, 4:21 AM
Gordon
Gordon - avatar
7th Jan 2020, 5:51 AM
el3be
el3be - avatar
0
https://code.sololearn.com/ccHdhgoKlLtV/?ref=app It can help you
7th Jan 2020, 6:15 PM
Anay Sah
Anay Sah - avatar
0
Leandro Blandi , Anay Sah : i kind of know how to do that, but this is a little different. ..
7th Jan 2020, 10:20 PM
Ginfio
Ginfio - avatar