Rock Paper Scissors

Tech Stack

CSS | HTML | JavaScript | React

Code & Live Demo

project overview

This react web application allows users to play the classic game against the computer. It provides the option for the user to  enter a nickname, make a choice between Rock, Paper, or Scissors, and play against the computer.

It dynamically provides an instant response for the result and keeps score of previous games played. This app provides a clean and user-friendly design.

rps hero

what I did

The game state is efficiently managed using React Hooks, specifically using React Hooks (useState), to track essential variables such as ‘playerChoice’, ‘computerChoice’ and ‘playerName’. This approach ensures real-time updates and a responsive user experience.

To handle the game logic I utilised, arrays and objects that are strategically employed, allowing for dynamic message generation based on the game’s outcomes. The application follows a multi-class design with separate classes for styling and layout.

rps code snippet

summary

Overall, it was a great project to stretch my skills in react hooks, such as useState. I also learned a lot about node package management when using the Vite development server.

react rps giphy

Developed with ♥ by Ray Brown

0.18g of CO2/viewWebsite Carbon
 Cleaner than 82% of pages tested