The Rock-Paper-Scissors Game
HTML and CSS allow you to present nicely formatted and hyperlinked pages of content for users to read. Applications however often need to accept user inputs and process the inputs to provide enhanced functionality. This is achieved using HTML elements known as Forms and Input Fields and a third language known as JavaScript.
JavaScript is a very powerful language and today’s it’s use has expanded to write sophisticated applications, not only in web pages but also as backend processes.
This example will show you how to write a complete interactive web application using HTML, CSS, and JavaScript. The application will enable you to play a simple version of the Rock-Paper-Scissors game with a computer.
The Rock-Paper-Scissors Game
If you are not familiar with the game here is a quick explanation. The game is played between two players who have to call out one of Rock, Paper, or Scissors at the same time. The winner for each round is defined by the following simple rules: Paper cover Rock (Paper wins), Rock breaks Scissor (Rock wins), and Scissor cuts Paper (Scissor wins). In the real life version when calling each player also has to make a sign for each of the three options. A closed fist 👊 is a Rock, a flat palm ✋ is Paper, and two forefingers in a V-shape ✌ is a Scissor.