dubtrotters

HTML Coin Flip

Apr 19th, 2019
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <button type="button" onclick="myFunction1()" id="Coin">CLick ME</button>
  2. <script>
  3.   function myFunction1() {
  4.     var x = Math.floor(Math.random() * 2);
  5.     console.log(x);
  6.     if (x == 0) {
  7.       document.getElementById("Coin").innerHTML = "HEADS";
  8.     } else {
  9.       document.getElementById("Coin").innerHTML = "TAILS";
  10.     }
  11.   }
  12.  
  13.   myFunction1();
  14. </script>
Advertisement
Add Comment
Please, Sign In to add comment