Conversation
| </div> | ||
|
|
||
|
|
||
| <script> |
There was a problem hiding this comment.
instead of adding code to html <script> create a separate file for JS.
There was a problem hiding this comment.
Ohk sir. I will take care from next time
| document.getElementById("myBtn").addEventListener("click", displayDate); | ||
| document.getElementById("myBtn1").addEventListener("click", displayPaper); | ||
| document.getElementById("myBtn2").addEventListener("click", displayScissor); |
There was a problem hiding this comment.
for this specific case we can add logic of querySelectorAll("botton"), and for each button click we can call a method that will update the scenario who win.
Re- write the code: using concept of:
querySelectorAll("botton"), use foreach, and onclick call one method that will update the state, also use ternary operator as user can win in three cases only
you_win = ( (you === "rock") && (opponent === "scissor") ||
(you === "paper") && (opponent === "rock") ||
(you === "scissor") && (opponent === "rock") ) // returns true for your win cases only.
There was a problem hiding this comment.
I will update my code sir . Thank you for the help
Exclusive game please check it out