Closed Abhisheksingh0303 closed 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.
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.