title: Javascript date array, filling in missing days incrementaly
body: <p>I'm trying to display a graph with Flot. My data array does not have a date set if there is no value for that date. I've followed the accepted answer in <a href="https://stackoverflow.com/questions/14522667/how-to-configure-flot-to-draw-missing-time-series-on-y-axis-at-point-zero">this question</a> to 'fill in the gaps', but I now want the value to be the last value, and not 0. I can't get my head around how to get the previous date's value. I've tried getting the previous value with <code>var previousTotal = date[i][1];</code>, but I can't seem to get the right part of the array no matter what I try.</p>
  
  <p>Can anyone help please?</p>
  
  <pre><code>function fillInGapsAdding(data) {
        var startDay = data[0][0],
          newData = [data[0]];
  
  
          // Loop through all items in array
        for (i = 1; i &lt; data.length; i++) {
          var diff = dateDiff(data[i - 1][0], data[i][0]);
          var startDate = new Date(data[i - 1][0]);
          if (diff &gt; 1) 
          {
            for (j = 0; j &lt; diff - 1; j++) 
            {
              var fillDate = new Date(startDate).setDate(startDate.getDate() + (j + 1));
              var previousTotal = date[i][1];
                newData.push([fillDate, 0]);
            }
          }
          newData.push(data[i]);
        }
        return newData;
      }
  </code></pre>