SuperSimpleDev / javascript-course

682 stars 552 forks source link

Update 10-rock-paper-scissors.html #46

Closed Abhisheksingh0303 closed 12 months ago

Abhisheksingh0303 commented 12 months ago

In this updated code:

I added the data-choice attribute to each button element to store the player's choice. I used a loop to add a click event listener to each button. I created an object called outcome to store the game outcomes for each choice. The game logic is simplified by using this outcome object to determine the winner, loser, or tie. I updated the score and displayed it on the web page. I used a ternary operator to determine the result message based on the scores.

Abhisheksingh0303 commented 12 months ago

In this updated code:

I added the data-choice attribute to each button element to store the player's choice. I used a loop to add a click event listener to each button. I created an object called outcome to store the game outcomes for each choice. The game logic is simplified by using this outcome object to determine the winner, loser, or tie. I updated the score and displayed it on the web page. I used a ternary operator to determine the result message based on the scores.