title: Coin toss with JavaScript and HTML
body: <p>I need help fixing my script. Basically, I want it to flip a coin and update a <code>&lt;span&gt;</code> with the result, i.e. if it's heads or tails. At the moment, nothing happens when I click the button.</p>
  
  <p><strong>JavaSript:</strong></p>
  
  <pre><code>var heads = 0;
  var tails = 0;
  function click() {  
      x = (Math.floor(Math.random() * 2) == 0);
      if(x){
          flip("heads");
      }else{
          flip("tails");
      }
  };
  function flip(coin) {
      document.getElementById("result").innerHTML = coin;
  };
  </code></pre>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;button id="click" type="button"&gt;CLICK ME&lt;/button&gt;
  &lt;p&gt;
      You got: &lt;span id="result"&gt;&lt;/span&gt;
  &lt;/p&gt;
  </code></pre>