include var declaration for i in indexGivenDates()

this was throwing an error for me in Google Apps Script
put var i into a single declaration at top of function
Merge pull request #355 from joelkraft/master

include var declaration for i in indexGivenDates()