Basic Web Game using HTML5, CSS3, JS
-
User Makes a Choice:
- The function starts by noting the user's choice.
-
Computer Makes a Choice:
- The computer randomly picks between "rock", "paper", and "scissors".
-
Check for a Draw:
- If the user's choice is the same as the computer's choice, the game is a draw and a message indicating this is displayed.
-
Determine the Winner:
- If it's not a draw, the function checks which choice beats the other:
- "Rock" beats "Scissors".
- "Paper" beats "Rock".
- "Scissors" beat "Paper".
- Based on this comparison, it determines whether the user or the computer wins.
- If it's not a draw, the function checks which choice beats the other:
-
Update Scores and Messages:
- If the user wins, their score is increased by one, and a winning message is displayed.
- If the computer wins, its score is increased by one, and a losing message is displayed.
-
Repeat the Process:
- Event listeners ensure that each time the user makes a choice, the game logic is executed again.