The game allows the user to play against a 'computer' which responds to the user's selection by choosing between the three choices of 'rock', 'paper' or 'scissors'. Although I have previously made a game similar to this using vanilla javascript, I wanted to take the opportunity to build it in React JS in order to solidify my understanding of React.
The project primarily makes use of the useState hook to manage the different states in the game like the user's choice, the computer's choice and the result's display. The project also make use of the useEffect hook to manage the re-rendering of the app based on a number of dependencies. Some aspects that proved challenging initially include the managing the state's between the user and the computer's choice and the if else
loop which was rendering prematurely prior to incorporating the useEffect hook.
- React JS
- Javascript
- CSS
- User selects from a choice of three (rock, paper, scissors)
- Computer selects a random choice from either rock, paper, scissors
- A counter keeps count of the live score
- The first player to reach a score of 5 wins the game
- Clone the repo
git clone https://github.com/Hajara-I/rock-paper-scissors-repo.git
- Install NPM packages
npm install
- Run start to view project in your localhost browser
npm run start
- Allow users to login and add a username