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?
47 Replies
Queequeg
Queequeg2y ago
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.
Sste
Sste2y ago
woww. What can I do to resolve it?
Joao
Joao2y ago
Actually it looks like its inside the randomItems function, or?
Queequeg
Queequeg2y ago
I am immediately wrong, I missed the context.
Joao
Joao2y ago
@Sstephanyyy Can you share the code over on codepen.io or similar?
Sste
Sste2y ago
yes, it is inside yeaH. Just a moment,pls
Joao
Joao2y ago
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
glutonium
glutonium2y ago
it doesn't show any errors? in console
Sste
Sste2y ago
not
Sste
Sste2y ago
in the console, show the computer choice
Queequeg
Queequeg2y ago
I like your style @Sstephanyyy - it looks good.
Sste
Sste2y ago
thanks. Sorry, it is in another language
Queequeg
Queequeg2y ago
The problem appears to be that the logic that does the judging isn't getting called on the click.
Sste
Sste2y ago
really? why?
Want results from more Discord servers?
Add your server