title: Checking if local files are available
body: <pre><code>&lt;script&gt;
          var test;
  
      function gameExists() {
      var http = new XMLHttpRequest();
      http.open('HEAD', "/flappy.html", false);
      http.send();
      if(http.status!=404){
          test= "true";
      }else{
          test == "false";
      }
  
  }
      &lt;/script&gt;
  
  &lt;script&gt;
  if(test=="true") {
      alert('Game exists, add some code.');
  } else {
      alert('Download Game !');
  $('#frame').append('&lt;a href="path/to/flappy.html"&gt;Download&lt;/a&gt;');}
  
  &lt;/script&gt;
  </code></pre>
  
  <p>This is my javascript, to check if a local file is available. This is
  being hosted locally so I can not use any server side languages. So I
  am not sure what I have done wrong. Please help me, make this work. A)
  It doesn't check correctly B) It doesn't download . Thank you :)
  I am not sure why this code is not currently working, please help me
  out! What am I doing wrong?</p>