title: How do I reset my counter when it gets to the end of my array?
body: <p>I have a button that iterates through an array on click and displays the contents of the array. When I get to the end of the array, I would like to set the counter back to the beginning. Here is my code so far:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="likes"&gt;
  &lt;span class="figure"&gt;
  &lt;/span&gt;
  &lt;/div&gt;
  &lt;button type="button" id="like" &gt;Like&lt;/button&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>var clicks = 0; $("#like").click(function(){ clicks++; 
  $('.figure').html(clicks);});
  </code></pre>
  
  <p>working demo: <a href="http://jsfiddle.net/nTmu7/2/" rel="noreferrer">http://jsfiddle.net/nTmu7/2/</a></p>