title: Next and Previous Arrow Buttons to Navigate through Web URLs With JavaScript
body: <p>I am very new to JavaScript so please bear with me. 
  I am trying to create a next and previous arrow navigation that will cycle through a group of web pages but I am missing a key piece of code that keeps track of which web page I am on so it can determine the sequence. Any help is most appreciated!</p>
  
  <p>This is the script I have written so far:</p>
  
  <pre><code>"use strict";
  var myPage = [];
  myPage[0] = "apples";
  myPage[1] = "oranges";
  myPage[2] = "bananas";
  myPage[3] = "kiwi";
  
  var myPageSrc = "file:///D:site/fruit/";
  
  var myPageEnd = ".html";
  
  var i = 0;
  
  function loadPage(){
    window.location.assign(myPageSrc + myPage[i] + myPageEnd);
  }
  
  function prev(){
    if (i &lt;= 0) {
      i = myPage.length;
      loadPage();
    } else {
      i = i - 1;
      loadPage();
    }
  }
  
  function next(){
    i = i + 1;
    if (i &gt;= myPage.length) {
      i = 0;
      loadPage();
    } else {
      loadPage();
    }
  }
  </code></pre>
  
  <p>And here is my HTML:</p>
  
  <pre><code>&lt;div class = "col-md-2"&gt; 
  &lt;a href="" class="nav-prev floatleft" original-title="Previous" onClick="prev();return   false;"&gt; &lt;img src="../img/left.png"&gt; &lt;/a&gt;
  &lt;a href="" class="nav-prev floatright" original-title="Next" onClick="next();return false;"&gt; &lt;img src="../img/next.png"&gt; &lt;/a&gt;
  &lt;/div&gt;
  &lt;script src="../js/nextprevnav.js"&gt;&lt;/script&gt;
  </code></pre>