<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Kathy Liu</title>
    <description>The latest articles on Forem by Kathy Liu (@kathyliu20).</description>
    <link>https://forem.com/kathyliu20</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F435631%2F106d211f-90c2-49ed-9cad-a34d8d1df776.jpg</url>
      <title>Forem: Kathy Liu</title>
      <link>https://forem.com/kathyliu20</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/kathyliu20"/>
    <language>en</language>
    <item>
      <title>Introduction to Web Animations using CSS</title>
      <dc:creator>Kathy Liu</dc:creator>
      <pubDate>Sun, 30 Aug 2020 17:21:40 +0000</pubDate>
      <link>https://forem.com/bitproject/introduction-to-web-animations-using-css-hpa</link>
      <guid>https://forem.com/bitproject/introduction-to-web-animations-using-css-hpa</guid>
      <description>&lt;p&gt;Animation is an important element of an interactive web page. CSS allows us to create simple movements of HTML objects by using the animation properties. Let us take a look at these properties, and use them to elaborate on our miniature city.&lt;/p&gt;

&lt;p&gt;Before we start, I hope you have already built the background of the miniature city by following the previous tutorials in this series, please check out the other bit project blogs! Or you can also check out our YouTube tutorial and get started!&lt;/p&gt;

&lt;p&gt;In this tutorial, We will focus on building a car going along the road and the bridge as well as a boat going under the bridge.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eYBXIw03--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/9FFPgkl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eYBXIw03--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/9FFPgkl.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Build the car and the boat
&lt;/h2&gt;

&lt;p&gt;First, let's build our car and boat with HTML and CSS, just like we did for the ground and buildings before.&lt;br&gt;
The car is a rectangle box, and the boat is a rectangle box with a triangle in the front. Both of them have a shadow to help show the three-D effect.&lt;br&gt;
So we need to have two divs for the car and the boat, and inside each of them, we will have some children divs. Children divs are divs inside a parent div. They are associated to their parent and can be easily aligned with their parent div. The two children divs under the car are to hold the left and front side rectangles while the three children divs under the boat are to hold the triangle in the front and the left and front side rectangles.&lt;/p&gt;
&lt;h5&gt;
  
  
  In HTML
&lt;/h5&gt;


&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class = "car"&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;div class = "boat"&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h5&gt;
  
  
  In CSS
&lt;/h5&gt;

&lt;p&gt;Now in CSS, try to build the car and the boat on your own by following the similar methods we used for the buildings.&lt;br&gt;
We could build the rectangle body under &lt;code&gt;.car&lt;/code&gt;. Remember that the codes under &lt;code&gt;.car{/*codes*/}&lt;/code&gt; will be applied to the entire class named &lt;code&gt;car&lt;/code&gt;. Use &lt;code&gt;box-shadow: /*styles*/&lt;/code&gt; &lt;a href="https://www.w3schools.com/cssref/css3_pr_box-shadow.asp"&gt;(refer to box-shadow syntax)&lt;/a&gt; to create the shadow both under the car and the boat.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JPnkvKWI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/HRqlOB3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JPnkvKWI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/HRqlOB3.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4BZICoJa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/iHeoG1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4BZICoJa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/iHeoG1y.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, we could work on the child divs. We can refer to the first child and the second child of the car by using &lt;code&gt;.car div:first-child&lt;/code&gt; and &lt;code&gt;.car div:nth-child(2)&lt;/code&gt;. These divs are the two parallelograms on the sides and the additional triangle for the boat. The parallelograms are skewed from rectangles using &lt;code&gt;transform: skew(/*styles*/)&lt;/code&gt; &lt;a href="https://www.w3schools.com/css/css3_2dtransforms.asp"&gt;(refer to skew() method)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AUNcq_oy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/u8mhDsM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AUNcq_oy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/u8mhDsM.png" alt=""&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k83hHybJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/3Uu1ORO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k83hHybJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/3Uu1ORO.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Movements with CSS
&lt;/h2&gt;

&lt;p&gt;Now that we have built our car and boat, we want them to move along the road and the ocean. We will do this by using CSS properties!&lt;br&gt;
CSS is a style sheet with many strong features, and we will be using CSS &lt;code&gt;animation&lt;/code&gt; and &lt;code&gt;@keyframes&lt;/code&gt; to create our customized movements.&lt;/p&gt;
&lt;h3&gt;
  
  
  CSS Animation
&lt;/h3&gt;

&lt;p&gt;CSS animations have the following properties:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;animation-name
animation-duration
animation-timing-function
animation-delay
animation-iteration-count
animation-direction
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We could set these properties of the objects (e.g. the car and the boat) to make them move. The &lt;code&gt;animation&lt;/code&gt; will gradually change the object from one set of styles to another, as indicated by the codes associated with the &lt;code&gt;animation-name&lt;/code&gt;. This animation will last for the amount of time that you set &lt;code&gt;animation-duration&lt;/code&gt; to. Also, we will use &lt;code&gt;@keyframes&lt;/code&gt; to create our customized animation.&lt;/p&gt;

&lt;p&gt;The above six properties can also be written shortened in one line in that order. For example,    &lt;code&gt;animation: example 5s linear 2s infinite alternate;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Therefore, for the boat, we will have &lt;br&gt;
&lt;code&gt;animation: boat 15s linear infinite;&lt;/code&gt; in the &lt;code&gt;.boat&lt;/code&gt; , which means the boat will change from one style to another as &lt;code&gt;@keyframes boat&lt;/code&gt; shows in 15 seconds, and then it will repeat infinite times.&lt;br&gt;
Similarly, the car will have &lt;code&gt;animation: car 9s linear infinite;&lt;/code&gt; to change the car as &lt;code&gt;@keyframes car&lt;/code&gt; shows in 9 seconds and repeat.&lt;/p&gt;

&lt;h3&gt;
  
  
  @keyframes
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;@keyframes&lt;/code&gt; will set the specific styles throughout the whole animation process. The whole process is indicated by &lt;code&gt;100%&lt;/code&gt;, so we could set different styles at different stages to create the animation. The &lt;code&gt;0% {/*starting style*/}&lt;/code&gt; shows the starting stage, where we want our boat to start at position &lt;code&gt;top: 60px; left: 20px;&lt;/code&gt;. Then, we can set the ending position using &lt;code&gt;100% {/*ending style*/}&lt;/code&gt;, where we are moving it to this position &lt;code&gt;top: 150px; left: 220px;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, we will start to move the car. This is similar to what we did for the boat, but we want the car to go onto the bridge; so, we break its route into five parts.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wv6_uKcb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/3EtTnGI.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wv6_uKcb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/3EtTnGI.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;go straight along the road:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   0% {
       top: 240px;
       left: -75px;
   }
   39% {
       top: 190px;
     left: 100px;
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;climb on to the bridge:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   39% {
       top: 190px;
       left: 100px;
   }
   50% {
    top: 170px;
       left: 150px;
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;go along the bridge:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   50% {
       top: 170px;
       left: 150px;
   }
   65% {
    top: 144px;
       left: 240px;
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;go down the bridge:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   65% {
       top: 144px;
       left: 240px;
   }
   73% {
       top: 145px;
       left: 280px;
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;go along the rest of the road:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   73% {
       top: 145px;
       left: 280px;
   }
   100% {
       top: 95px;
       left: 450px;
   }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By moving the car and the boat, we learned how to use the animation properties in CSS. These properties can help create many interactive and interesting elements in our web pages. There are more CSS properties that you can explore on your own in the future. Moving on, please check out the next tutorial blog about using JavaScript to create a button to change from daytime to night time in our miniature city and get introduced to another interesting and useful tool in web development -- JavaScript!&lt;/p&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Building a Charades Game In JavaScript</title>
      <dc:creator>Kathy Liu</dc:creator>
      <pubDate>Sun, 19 Jul 2020 19:34:16 +0000</pubDate>
      <link>https://forem.com/bitproject/building-a-charades-game-in-javascript-3c0b</link>
      <guid>https://forem.com/bitproject/building-a-charades-game-in-javascript-3c0b</guid>
      <description>&lt;p&gt;Life during quarantine has been boring without being able to hang out with friends or buy boba. Everyone is looking for new ways to have some fun at home. I recently read a post about creating a &lt;a href="https://medium.com/free-code-camp/vanilla-javascript-tutorial-build-a-memory-game-in-30-minutes-e542c4447eae"&gt;memory game using Vanilla JavaScript by Marina Ferreira&lt;/a&gt;, and found the techniques she used very interesting. So I decided to create another popular game — Charades — using similar techniques and adding more features; in this tutorial, we will dive a little deeper into JavaScript methods than the original. We will use HTML and CSS to help us build the basic interface of the pages, and we need JavaScript to add functions to the elements of the game. Let's build our own Charades game while learning HTML/CSS and JavaScript!&lt;/p&gt;

&lt;h3&gt;
  
  
  Live Demo: &lt;a href="https://cotton-broadleaf-pufferfish.glitch.me/"&gt;Charades!&lt;/a&gt;
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Download Starter Code
&lt;/h2&gt;

&lt;p&gt;Before we start, you can find all the code here:  &lt;a href="https://github.com/bitprj/Charades_Game_In_JavaScript"&gt;Charades_Game_in_JavaScript Repo&lt;/a&gt;. &lt;br&gt;
You can download the folder &lt;strong&gt;"starter"&lt;/strong&gt; directly, or you can also start from scratch by creating &lt;strong&gt;5 HTML files, 3 CSS files, and 4 JavaScript files in one single folder.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Don't get scared by the amount of files to create! Two of the HTML files are just the starting and ending page, which are very simple, and their corresponding CSS and JavaScript files have a lot in common!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;All of the &lt;strong&gt;HTML&lt;/strong&gt; files have the same starting template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;

  &amp;lt;title&amp;gt;Charades&amp;lt;/title&amp;gt;

  &amp;lt;link rel="stylesheet" href="{{YOUR_CSS_NAME}}"&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

  &amp;lt;script src="{{YOURJAVASCRIPTNAME}}"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;All &lt;strong&gt;CSS&lt;/strong&gt; files also have the same template to start, as we are simply setting the background color and layout here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
  }

  body {
    height: 100vh;
    display: flex;
    background: #f8e5a6;
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro tip&lt;/strong&gt;: I like to use &lt;a href="https://code.visualstudio.com/"&gt;Visual Studio Code&lt;/a&gt; to write all my code, since it color-codes the code and makes it easier to read. You should try it out if you don't know where to start!&lt;/p&gt;

&lt;p&gt;Now that we have all our files created, we can move on to the first step — creating the starting and ending page!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S7Zm-19Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9VQL74c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S7Zm-19Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9VQL74c.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting Page and Ending Page
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Starting Page
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8lsfMCIH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/2hL51bx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8lsfMCIH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/2hL51bx.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the starting page, we want to insert a button so the player can click on it to start the game. To create a button, use the &lt;code&gt;&amp;lt;button&amp;gt;&amp;lt;/button&amp;gt;&lt;/code&gt; tag in HTML.&lt;/p&gt;

&lt;p&gt;You can play around with the design of the button in the corresponding CSS file "styles.css." Now let's focus on adding the effect when the button is clicked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in HTML:&lt;/strong&gt;&lt;br&gt;
First, the tag &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; can have an &lt;strong&gt;"onclick"&lt;/strong&gt; event, which calls the function &lt;code&gt;start()&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uVx3EXFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/aFkiBAS.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uVx3EXFg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/aFkiBAS.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make the button work, we need to write the function in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;br&gt;
We want to go to the next page of the game when the start button is clicked.&lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;function start() {}&lt;/code&gt; would only have one line to jump to the next HTML page using &lt;code&gt;window.location&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5_W_TGUy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/eV0yayP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5_W_TGUy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/eV0yayP.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in CSS:&lt;/strong&gt;&lt;br&gt;
Here is an example design of the start button, but you can customize yours by playing around with the features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ACIsLn9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hpqyiQl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ACIsLn9J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/hpqyiQl.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Tip: Linking Two HTML Files
&lt;/h3&gt;

&lt;p&gt;As we jump from the starting page to the next page, we switch into another HTML file. In order to make this happen, we need to add another line of code in our HTML file.&lt;/p&gt;

&lt;p&gt;Use the tag &lt;code&gt;&amp;lt;a href="{{YOUR_NEXT_HTML_NAME}}"&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt; under the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag in your starting page's HTML. Now check out the page — the start button should be working!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MSUr7kly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/HSesBXq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MSUr7kly--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/HSesBXq.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Ending Page
&lt;/h3&gt;

&lt;p&gt;In the &lt;a href="https://cotton-broadleaf-pufferfish.glitch.me/"&gt;live demo&lt;/a&gt;, we see that the ending page is just a page with one single line of words to show a finishing message.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLr4w5uW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/bBJIeDc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZLr4w5uW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/bBJIeDc.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To do this, we can simply write in the HTML file.&lt;br&gt;
A simple header shows the message, but we want it to be wrapped by a section so the text is centered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
    &amp;lt;section&amp;gt;
        &amp;lt;h1&amp;gt;Times up!&amp;lt;/h1&amp;gt;
    &amp;lt;/section&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since this is a very simple page, we don't need a script file to add functions to it. Instead of using a separate CSS file to style the contents, we can simply add &lt;code&gt;style="..."&lt;/code&gt; in each tag to customize the style.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the Game Rules
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RT_k4Cpk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4yewZS5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RT_k4Cpk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/4yewZS5.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The start button redirects us to the second page where we can choose the version of the game we want to play. One is called "Limiting Time," where you get 30 seconds per card for a set number of words, and the other is "How Many Words," where you get 5 minutes total and you skip through cards as fast as you want to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Want to play the game right now? Skip this page! Jump directly to the "Creating Animated Word Cards" section about your preferred version!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in HTML:&lt;/strong&gt;&lt;br&gt;
On this page, we want to have two buttons which redirect to two different HTML pages. The buttons are created in the same way as the start button on the starting page. We add a &lt;code&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/code&gt; tag to create the text box under each button.&lt;/p&gt;

&lt;p&gt;Create two &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tags with class names "v1" and "v2" for the two buttons under the &lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt; tag first. These containers will allow us to set the positions of the buttons and the text box in CSS later.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;&amp;lt;br&amp;gt;&amp;lt;/br&amp;gt;&lt;/code&gt; tags if you want to create blank lines.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dMcCJa_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/J6igzUP.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dMcCJa_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/J6igzUP.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in CSS:&lt;/strong&gt;&lt;br&gt;
We can design our button in the corresponding "chooseVer.css" file. To set the style of the entire class, use &lt;code&gt;.&lt;/code&gt; in front of the class name, or use &lt;code&gt;#&lt;/code&gt; to reference by the ID name. You could also set styles for everything under a tag by directly putting &lt;code&gt;p {...}&lt;/code&gt; for the text, for example.&lt;/p&gt;

&lt;p&gt;There are many ways to center a text box or a container. Here I set &lt;code&gt;margain-top&lt;/code&gt;, &lt;code&gt;margain-bottom&lt;/code&gt;, &lt;code&gt;margain-left&lt;/code&gt;, and &lt;code&gt;margain-right&lt;/code&gt; to &lt;code&gt;auto&lt;/code&gt;, and aligned the text of the bigger containers to the &lt;code&gt;center&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LwUCw5i3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/yT1TagC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LwUCw5i3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/yT1TagC.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This process is similar to the starting page, but now we will have two separate functions that correspond to each of the buttons (invoked by &lt;code&gt;onclick&lt;/code&gt;) to redirect to different pages.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;function time() {}&lt;/code&gt; will take us to &lt;code&gt;"card_time.html"&lt;/code&gt;, and the &lt;code&gt;function word() {}&lt;/code&gt; will take us to &lt;code&gt;"card_word.html"&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Challenge: Adding a Countdown Before Redirecting&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OHNsdKfa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/FaGi3Yk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OHNsdKfa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/FaGi3Yk.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Not ready for the game to start right away? Let's create a 5-second countdown timer before it starts!&lt;/p&gt;

&lt;p&gt;There are many ways to add the timer before redirecting. For example, you can add another HTML file, in which you would create a simple countdown timer, and then redirect to the corresponding page (this is a little hard). You can also add the timer either in the same page as the choosing buttons or separately in the two card files. Here, we will try the most straightforward way by adding the timer in the "chooseVer.html" page and countdown before redirecting.&lt;/p&gt;

&lt;p&gt;The timer will be created under the &lt;code&gt;&amp;lt;span&amp;gt;&amp;lt;/span&amp;gt;&lt;/code&gt; tag in the HTML file.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--71xAopxG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/l5aeE0C.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--71xAopxG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/l5aeE0C.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The timer will be exactly the same in both versions of the game. Let's start by adding it to the &lt;code&gt;"Limiting Time"&lt;/code&gt; version first.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Part 1: Hide And Show&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It is important to notice that in the beginning, before the player makes a choice, the countdown should not be shown on the page, so we need to "hide" the timer at first. Then, after one of the buttons is clicked, the countdown will "show".&lt;br&gt;
Inspired by the original post, we include the "hide" and "show" properties in the CSS file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in CSS:&lt;/strong&gt;&lt;br&gt;
You can set the style of the timer by its tag name. Make sure you include &lt;code&gt;display: none;&lt;/code&gt; so that it is not shown in the beginning.&lt;br&gt;
The &lt;code&gt;none&lt;/code&gt; indicates it is not showing, and &lt;code&gt;block&lt;/code&gt; indicates it is showing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--57Sss3Ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/2rYdVql.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--57Sss3Ew--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/2rYdVql.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;br&gt;
When the button is clicked, we want the buttons and the text to disappear, and the countdown timer to show up. Therefore, inside functions &lt;code&gt;time()&lt;/code&gt; and &lt;code&gt;word()&lt;/code&gt;, we need to hide the text and the buttons.&lt;/p&gt;

&lt;p&gt;Here we will show how to do this in the &lt;code&gt;time()&lt;/code&gt; function. This is implemented in the exact same way in &lt;code&gt;word()&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hide Text:
To select the text boxes, we set a variable &lt;code&gt;var element = document.getElementById("intro-words");&lt;/code&gt;. Then, we modify the style of this element into &lt;code&gt;"hide"&lt;/code&gt; by using &lt;code&gt;.classList.toggle()&lt;/code&gt;. Do the same for the &lt;code&gt;"intro-time"&lt;/code&gt; text box.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FTGYDD9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/0NXOPNd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FTGYDD9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/0NXOPNd.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hide Buttons:
Since there are two buttons under the &lt;code&gt;but&lt;/code&gt; class, we need to select them with &lt;code&gt;const button = document.querySelectorAll('.but');&lt;/code&gt;, then access each of them by using &lt;code&gt;forEach(but =&amp;gt; but...);&lt;/code&gt; The buttons have a style property called visibility, so we set it to "hidden".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--J6P0SQHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/VNnoB6d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J6P0SQHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/VNnoB6d.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Show Counter:
Same as hiding the text boxes, we select the timer element by its ID &lt;code&gt;"go"&lt;/code&gt;, and use &lt;code&gt;.classList.toggle&lt;/code&gt; to set it to &lt;code&gt;"show"&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Part 2: Timer&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now we can implement the timer.&lt;br&gt;
The idea is that the timer will take in the &lt;code&gt;textContent&lt;/code&gt; of our &lt;code&gt;"go"&lt;/code&gt; element, and show the modified &lt;code&gt;textContent&lt;/code&gt; every one second. We update the &lt;code&gt;textContent&lt;/code&gt; by keeping a counter and decrementing it every second.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;br&gt;
We first create a variable &lt;code&gt;seconds&lt;/code&gt; to hold the value in the &lt;code&gt;textContent&lt;/code&gt; of our &lt;code&gt;"go"&lt;/code&gt; element, which is 5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aEU8kELL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/itWasch.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aEU8kELL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/itWasch.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, we use the &lt;code&gt;setInterval()&lt;/code&gt; function to let the timer count down at each second (=1000 milliseconds), and update the variable &lt;code&gt;seconds&lt;/code&gt; by using the decrementing operator &lt;code&gt;seconds--;&lt;/code&gt;. Then update the &lt;code&gt;textContent&lt;/code&gt; with the decremented seconds or whatever words you want (like "Ready?" "Go!").&lt;/p&gt;

&lt;p&gt;We use an &lt;code&gt;if-else if-else&lt;/code&gt; loop to separate conditions on the seconds. The seconds go into the &lt;code&gt;else&lt;/code&gt; statement after 5 iterations, and we use &lt;code&gt;clearInterval(count);&lt;/code&gt; to jump to the corresponding page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9F-PtUCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/k6gd2dv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9F-PtUCy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/k6gd2dv.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now try out the new feature for your "Limiting Time" version! &lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Part 3: Copy to Both Functions&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;br&gt;
Simply copy and paste all the code we added in the function &lt;code&gt;time()&lt;/code&gt; in parts 1 and 2 into the function &lt;code&gt;word()&lt;/code&gt;. Remember to change the redirecting page into &lt;code&gt;"card_word.html"&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;Now, try clicking both of the buttons!&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating Animated Word Cards
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ln00BDRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9XlNjfr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ln00BDRQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9XlNjfr.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now for the exciting part — creating flipping cards with words on them!&lt;br&gt;
Let's start with creating the elements in HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in HTML:&lt;/strong&gt;&lt;br&gt;
The HTML of both versions of how you play the game are exactly the same, besides the different JavaScript they include.&lt;/p&gt;

&lt;p&gt;There will be a simple &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; tag holding the card which has a &lt;code&gt;front-face&lt;/code&gt;, and a &lt;code&gt;back-face&lt;/code&gt;. I adapted a procedure from the original blog to create the flipping card. I also added a timer to give a reference to the players.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="cards" id="words"&amp;gt;
    &amp;lt;p class="front-face" id="word2"&amp;gt;dog&amp;lt;/p&amp;gt;
    &amp;lt;p class="back-face" id="word1"&amp;gt;pig&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;span id="timer"&amp;gt;&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;in CSS:&lt;/strong&gt;&lt;br&gt;
Since both versions have the same HTML elements, we do not need to create separate CSS files for each design (but you can if you want the cards to look different).&lt;br&gt;
Besides the design of cards, there are some important features to add to make the card flips. I mainly adapted these &lt;a href="https://github.com/code-sketch/memory-game/blob/master/video-11/styles.css"&gt;CSS codes&lt;/a&gt; from &lt;a href="https://medium.com/free-code-camp/vanilla-javascript-tutorial-build-a-memory-game-in-30-minutes-e542c4447eae"&gt;the original blog post&lt;/a&gt;, because the flipping effects are very fluid and attractive. However, instead of flipping them vertically, I flipped them horizontally, so we have &lt;code&gt;transform: rotateX(180deg);&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can find my full CSS code &lt;a href="https://github.com/bitprj/Charades_Game_In_JavaScript/blob/master/finish_code/cardstyle.css"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nVz32_Sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/r8J1YZg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nVz32_Sk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://i.imgur.com/r8J1YZg.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is a little tricky. Since I used the same CSS codes from the original blog, the &lt;code&gt;back-face&lt;/code&gt; is shown in the beginning as the first word, so I named it &lt;code&gt;id="word1"&lt;/code&gt;. I'll refer to all the words as &lt;code&gt;word1&lt;/code&gt;, &lt;code&gt;word2&lt;/code&gt;, etc. to make it more clear.&lt;/p&gt;

&lt;h3&gt;
  
  
  "Limiting Time" Version
&lt;/h3&gt;

&lt;p&gt;In this version, we want to use a timer to keep track of the time that each card has been shown, and flip the card when 30 seconds is up. The total game will last for 5 minutes. Play this with your friends to see how many words you can guess right in 5 minutes!&lt;br&gt;
To do this, we can write a function &lt;code&gt;function flipWord() {...}&lt;/code&gt; which flips the word, and then starts the timer. When 30 seconds is up, call &lt;code&gt;flipWord()&lt;/code&gt; again and reset the &lt;code&gt;textContent&lt;/code&gt; of whichever word was hidden, which will now be the next word shown. The first word when the game starts is the &lt;code&gt;back-face&lt;/code&gt; of the card, and the next word is the &lt;code&gt;front-face&lt;/code&gt; of the same card. However, after the first flip, if we flip the card again, the &lt;code&gt;back-face&lt;/code&gt; shows up again. So we want the next word to be on the &lt;code&gt;back-face&lt;/code&gt; of the card before we do the flip. Let's break this process up and implement it in JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The First Flip:
The first flip is different from the rest, because &lt;code&gt;word2&lt;/code&gt; is already there and we do not need to reset any words. So we use the same &lt;code&gt;setInterval()&lt;/code&gt; function from our previous timer and call &lt;code&gt;flipWord()&lt;/code&gt; instead of jumping to the next window. Set the time to 30 seconds.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Check out the timer implementation in part 2 of the "Challenge: Adding a Countdown Before Redirecting" section under "Choosing the Game Rules" if you skipped that part.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--haUUEyj4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9eTYQo6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--haUUEyj4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9eTYQo6.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;flipCard()&lt;/code&gt; Function:
When we call &lt;code&gt;flipCard()&lt;/code&gt;, we want to set the style corresponding to the "flip" we declared in the CSS file. This is similar to the "Hide and Show" strategy we used in the previous section. So we would simply have one line here: &lt;code&gt;document.getElementById("words").classList.toggle('flip');&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Go back and check out part 1 if you skipped it!&lt;/em&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Keep Flipping Cards and Resetting Words:
After the first flip, a new 30 second countdown should start, so we add the same timer again in the &lt;code&gt;flipWord()&lt;/code&gt; function after &lt;code&gt;toggle('flip);'&lt;/code&gt;. Now we are seeing &lt;code&gt;word2&lt;/code&gt; on the screen, and &lt;code&gt;word1&lt;/code&gt; is being hidden in the back. This is the time to change &lt;code&gt;word1&lt;/code&gt; secretly! How do we do that?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here we want to keep the single HTML file and add a counter to keep track of the new word.&lt;/p&gt;

&lt;p&gt;Declare a counter &lt;code&gt;var word-num = 1;&lt;/code&gt; outside of the function. It starts at 1 because we already flipped the first card. Then, the counter is incremented by 1 each time a word is guessed. In this way, we can keep track of how many words we have been guessed.&lt;/p&gt;

&lt;p&gt;The function should look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I3ONLsEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/T9AFvh8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I3ONLsEM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/T9AFvh8.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we reset the word each time by using &lt;code&gt;if&lt;/code&gt; statements to check the &lt;code&gt;word_num&lt;/code&gt; conditions. Remember that resetting words means changing the &lt;code&gt;textContent&lt;/code&gt; of &lt;code&gt;word1&lt;/code&gt;. Also be careful to note which word we are changing at each &lt;code&gt;word_num&lt;/code&gt;, &lt;code&gt;word1&lt;/code&gt; or &lt;code&gt;word2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is an example of how to set the 6th and 7th word.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dpUpYiHb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/BW8bVpH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dpUpYiHb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/BW8bVpH.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Finish Flipping:
After 10 words have been shown, we jump to the &lt;code&gt;endpage.html&lt;/code&gt; when &lt;code&gt;word_num == 11&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! Now we are done with the "Limiting Time" version. Try it out!&lt;/p&gt;

&lt;h3&gt;
  
  
  "How Many Words" Version
&lt;/h3&gt;

&lt;p&gt;In this version, we want to flip the card whenever the player clicks on it. We set a timer of 5 minutes, which is how long the game lasts, and you count how many words you get right!&lt;br&gt;
To do this, we first need to have a function &lt;code&gt;flipWord()&lt;/code&gt; to flip the card when we click on the card. This is a little different from the button clicking process, which we will look into shortly. We also want to recursively call &lt;code&gt;flipWord()&lt;/code&gt; and reset the next word.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;in JavaScript:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Clicking to Flip:
This is a little different from clicking the button, because we are clicking an element with the tag &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, which does not have an &lt;code&gt;onclick&lt;/code&gt; feature to add. So we need to add it ourselves. As shown in the original Memory Game, we use  &lt;code&gt;addEventlistener()&lt;/code&gt; to tackle with this clicking. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TOLka7Z2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/vq7pZ6f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TOLka7Z2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/vq7pZ6f.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when we click on the card, the &lt;code&gt;flipWord()&lt;/code&gt; function is called.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;flipWord()&lt;/code&gt; Function:&lt;br&gt;
Similar to the "Limiting Time" version, the function will have a line of &lt;code&gt;document.getElementById("words").classList.toggle('flip');&lt;/code&gt;, an incrementation of &lt;code&gt;word_num&lt;/code&gt;, and a call to &lt;code&gt;flipWord()&lt;/code&gt; again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resetting Word:&lt;br&gt;
We still have a similar strategy of resetting words by checking &lt;code&gt;word_num&lt;/code&gt;, and changing the corresponding word's &lt;code&gt;textContent&lt;/code&gt;. However, how do we know when to flip the card again? We know that we should flip the card whenever the card is clicked, and we used &lt;code&gt;addEventListener()&lt;/code&gt; to indicate the first time to flip the card, so what about the recursive method?&lt;br&gt;
Here we create another function &lt;code&gt;clicked()&lt;/code&gt; and a Boolean variable &lt;code&gt;CardIsClicked&lt;/code&gt; to indicate if the card is clicked. This strategy to check the clicked card is also introduced in the original Memory Game, but we will be using it differently.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g-RVj41Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/kazD4Kf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g-RVj41Y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/kazD4Kf.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We know that &lt;code&gt;CardIsClicked = true&lt;/code&gt; if we click on the card, so the &lt;code&gt;flipWord()&lt;/code&gt; function should be called recursively if &lt;code&gt;CardIsClicked == true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HT3Wsr-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/weZ4MH6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HT3Wsr-g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/weZ4MH6.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can reset the words in the exact same way as in the "Limiting Time" version by checking the &lt;code&gt;word_num&lt;/code&gt; conditions. However, after every reset, we want to make &lt;code&gt;CardIsClicked = false&lt;/code&gt;, because we want to keep showing it until the next click.&lt;/p&gt;

&lt;p&gt;I made this version with more words since you can skip unwanted words, but the words and numbers are all up to you!&lt;/p&gt;

&lt;p&gt;So now the resetting should look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iRCDsc8q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9TVlI5K.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iRCDsc8q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/9TVlI5K.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We are almost finished! This version should already be working pretty well, but it will only go to the end page when you click through all the words. But remember that we have a time limit! Let's create another timer.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Timer &lt;code&gt;setTimeOut()&lt;/code&gt;:
This time, we are not updating the time whenever the card is flipped, but rather using one clock to track the time. We still use the same  &lt;code&gt;setInterval()&lt;/code&gt; function as in all the other timers we've been created. However, this time we have both minutes and seconds, and we can print out the message a little clearer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4kZ13PNi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/i0cMgwK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4kZ13PNi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/i0cMgwK.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can add &lt;code&gt;window.location = "endpage.html"&lt;/code&gt; in this &lt;code&gt;else&lt;/code&gt; loop, but I want to introduce another technique to redirect the page. That is the &lt;code&gt;setTimeOut()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QGfcGkQN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/Myk5V3Z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QGfcGkQN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/Myk5V3Z.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While the &lt;code&gt;setTimeOut()&lt;/code&gt; is very useful if you do not want to show the countdown and redirect right after a certain amount of time, &lt;code&gt;setInterval()&lt;/code&gt; shows the countdown. These two strategies are both fairly straightforward.&lt;/p&gt;

&lt;p&gt;Now we are done implementing the "How Many Words" clicking version! Time to check out the full game. Refer to the finished code in the &lt;a href="https://github.com/bitprj/Charades_Game_In_JavaScript"&gt;repo&lt;/a&gt; if you get a different output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Congratulations again on following through this tutorial and creating your own Charades game! Now you can customize it and play with your families and friends.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advanced Challenges: Potential Improvements to the Game
&lt;/h3&gt;

&lt;p&gt;While this is a fairly easy and straightforward example of making a Charades game using HTML, CSS and JavaScript, there are some more advanced features we could implement in these game pages.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Would you be able to combine the two versions, where you can click on the card to skip or you finish before 30 seconds and want to move on, but you still want to keep a timed 30 seconds on each card?&lt;/li&gt;
&lt;li&gt;Would it be possible to generate words and assign them to each card when flipping?&lt;/li&gt;
&lt;li&gt;Would there be a way to let us input the words (either being asked on the webpage or write them as a list in the files) and randomly assign them to the cards, where it would not show up in the original order we input the words in?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Try answering these questions for a challenge!&lt;br&gt;
I hope you had fun learning HTML/CSS and JavaScript. You can use the skills you learned in this tutorial to keep building upon this game or try making a new one!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
