title: Global variable goes undefined on page refresh JAVASCRIPT
body: <p>I'm having an issue where my global variable for a counter is going undefined when refreshing page. Each time you navigate to another page it bumps the counter and it works fine... but as soon as you hit refresh it says "cannot read property 0 of undefined"</p>
  
  <p>My code:</p>
  
  <pre><code>var answer = function(currAnswer){
      if(answer[index].getAnswer !== currAnswer){
          return false;
     }
     else {
         return true;
      }
  }
  </code></pre>
  
  <p>It works fine until you refresh the page and then it complains about 0 being undefined? Index is the global var which is bumped up when navigating between pages...</p>
  
  <p>This isn't best practice but I'm still confused as to what is happening?</p>