title: Javascript display/calculate past 3 months
body: <p>I have a function that works out the past 3 months and displays the name by using an array. </p>
  
  <p>I've just realised that when the new year comes round, for January, February &amp; March, it won't be able to get the correct month. </p>
  
  <p>I want to be able to do this without having to add in a hack (which is the only way I've seen to do this)</p>
  
  <pre><code>function getMonths()
      {
          var today = new Date();             
          var month = 0;
          var currMonth = month-3;
  
          var monthArray = new Array("January","February","March","April","May","June",
                  "July","August","September","October","November","December");
  
          var menuMonths = new Array();
          var count = 4;
          var buffer = 10;
  
          while(count &gt;0)
          {           
              var month = monthArray[currMonth];
              alert(currMonth);
              menuMonths.push(month);
  
              currMonth = currMonth +1;
              count = count -1;
          }       
          return menuMonths;
      }   
  </code></pre>