title: Get the last item in an array
body: <p>Here is my JavaScript code so far:</p>
  
  <pre><code>var linkElement = document.getElementById("BackButton");
  var loc_array = document.location.href.split('/');
  var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2]))); 
  linkElement.appendChild(newT);
  </code></pre>
  
  <p>Currently it takes the second to last item in the array from the URL. However, I want to do a check for the last item in the array to be <code>"index.html"</code> and if so, grab the third to last item instead.</p>