title: How do I make this Javascript function open the site in a new tab?
body: <p>How do I make this function open the link in a new tab?
  I read somewhere that I should use an anchor element instead of using JS to open the link.</p>
  <pre><code>&lt;h1 onclick=&quot;randomSite();&quot;&gt;Click&lt;br&gt;Me&lt;/h1&gt;
              &lt;script&gt;
      var sites = [
          'www.google.com',
          'www.youtube.com',
          'www.facebook.com',
          'www.stackoverflow.com'
      ];
  
      function randomSite() {
          var i = parseInt(Math.random() * sites.length);
          location.href = sites[i];
      }
  &lt;/script&gt;
  </code></pre>