A Pen by Kshaunish

Thumbnail
This awesome code was written by Kingkoderkims, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright Kingkoderkims ©
  • HTML
  • CSS
  • JavaScript
    <html>
<head> 
  <style type="text/css">
    div.dice{
      float:left;
      width:32px;
      background:#F5F5F5;
      border: #999 1px solid;
      padding:10px;
      font-size:24px;
      text-align:center;
      margin:5px;
      
      
      
    } 
    
    
  </style>
  <script>
    function rollDice() {
      var die1 = document.getElementById("die1");
      var die2 = document.getElementById("die2");
      var status = document.getElementById("status");
      var d1 = Math.floor(Math.random() * 6) + 1;
      var d2 = Math.floor(Math.random() * 6) + 1;
      var diceTotal = d1 + d2;
      die1.innerHTML = d1;
      die2.innerhtml = d2;
      status.innerHTML = "You Rolled "+diceTotal+".";
      if (d1 == d2){
        status.innerHTML = "You Rolled A Double!, Get A Free Turn!!";
      }
    }
    
  </script>
  </head>
  <body>
    <div id="die1" class="dice">0</div>
    <div id="die2" class="dice">0</div>
    <button onclick="rollDice()">Roll Dice</button>
    <h2 id="status" style="clear:left;"></h2>
  </body>  
</html>


/*Downloaded from https://www.codeseek.co/Kingkoderkims/a-pen-by-kshaunish-MraqLq */
    


/*Downloaded from https://www.codeseek.co/Kingkoderkims/a-pen-by-kshaunish-MraqLq */
    

Comments