Skip to content

Conversation

@sami-odoo
Copy link

Exclusive game please check it out

</div>


<script>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding code to html <script> create a separate file for JS.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohk sir. I will take care from next time

Comment on lines +32 to +34
document.getElementById("myBtn").addEventListener("click", displayDate);
document.getElementById("myBtn1").addEventListener("click", displayPaper);
document.getElementById("myBtn2").addEventListener("click", displayScissor);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update my code sir . Thank you for the help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants