https://github.com/nziza-oscar/rock-paper-scissors
https://github.com/nziza-oscar/rock-paper-scissors
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/nziza-oscar/rock-paper-scissors
- Owner: nziza-oscar
- Created: 2023-07-08T23:01:20.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-08T23:50:09.000Z (almost 2 years ago)
- Last Synced: 2025-01-12T09:44:34.692Z (5 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rock-paper-scissors
## Explanation
-the **getComputerChoice()** function returns a randomly selected choice ('rock', 'paper', or 'scissors') for the computer.
-The **playRound()** function takes the player's selection and the computer's selection as parameters. *It converts both selections to lowercase for case-insensitive comparison. It then determines the winner based on the classic "rock paper scissors" rules and returns a string that declares the winner and the choices made*.
-The **game()** function handles the overall game logic. It initializes variables for the player's score and the computer's score. It uses a **for** loop to play 5 rounds of the game. In each round, it prompts the player for their choice, generates the computer's choice, and calls the **playRound** function. It updates the scores based on the result of each round and logs the result to the console.
-__After 5 rounds, the game function determines the overall winner based on the scores and logs the final result to the console__