+ 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
10 RĂ©ponses
+ 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
+ 1
default display none
in play(), set style.display
+ 1
use random syntax
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.
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...)
0
Gordon , display the buttons, none| block, when âROCKâ clicked?
0
yes, in css, display none
in button event listener, set their style.display block (or other appropriate value)
0
Check this men
https://code.sololearn.com/cgDhpLufWanI/?ref=app
0
https://code.sololearn.com/ccHdhgoKlLtV/?ref=app
It can help you
0
Leandro Blandi , Anay Sah :
i kind of know how to do that, but this is a little different.
..