If statement is NOT working
I am making a Rock, paper, scissor game. But the If statement of the code is not working. What can I do?
![](https://utfs.io/f/2238aff3-d732-4fbb-9b8b-d751974a6fe6-1nq2cb.png)
![](https://utfs.io/f/a842ae5f-69ef-45a0-8e3a-a207000d29f4-1nq2cb.png)
47 Replies
I am going to guess that you intend for the if statement to run after the
onclick
methods fire. Unfortunately, it is defined right on the window. So it gets called as soon as the file loads.woww. What can I do to resolve it?
Actually it looks like its inside the randomItems function, or?
I am immediately wrong, I missed the context.
@Sstephanyyy Can you share the code over on codepen.io or similar?
yes, it is inside
yeaH. Just a moment,pls
But actually I think you are correct in that the event listener is being added every time the function is called. Rather, the event listener should be moved up to the window. That may be it
it doesn't show any errors?
in console
not
in the console, show the computer choice
![](https://utfs.io/f/7a2548c2-9b65-4936-a94f-78ecf04dd3aa-1nq2cb.png)
I like your style @Sstephanyyy - it looks good.
thanks. Sorry, it is in another language
The problem appears to be that the logic that does the judging isn't getting called on the click.
really? why?