title: How to have multiple URLs in a let URL in JavaScript
body: <p>I have the following statement in my frontend JavaScript</p>
  <pre><code>let totalURL = &quot;http://total.40313993.qpc.hal.davecutting.uk&quot;;
  </code></pre>
  <p>I would like to add another URL to this, if the first one fails then use this URL. I have no idea how i would implement this in JavaScript any and all help is very welcome and appreciated.</p>
  <p>Where totalURL is used:</p>
  <pre><code>function getTotal()
  {
      input_text = document.getElementById('input-text').value + '-getTotal'
      if (input_text == '')
          return;
      else
      {
          input_text_edited = '';
          lines = input_text.match(/[^\r\n]+/g);
          for (let i = 0; i &lt; lines.length; i++) {
              if(i != (lines.length-1)){
                input_text_edited += lines[i] + &quot;newline&quot;;
              }
              else {
                input_text_edited += lines[i];
              }
          }
  
          let xhttp = new XMLHttpRequest();
          xhttp.onreadystatechange = function() {
              if (this.readyState == 4 &amp;&amp; this.status == 200) {
                  var j = JSON.parse(this.response);
                  total_marks = j['total_marks'];
                  displayTotal();
              }
          };
  
          xhttp.open(&quot;GET&quot;,totalURL+&quot;?input_text=&quot;+input_text_edited);
          xhttp.send();
  
          return;
      }
  
  }
  
  </code></pre>