I'm trying to separate each month's dates in each iteration. I have an array var selected=["pre populated with special dates"] which have all the selected dates. Now in this code how can I modify it to remove the dates for each month from selected[] array and populate thisMonthDates[] with only this particular month's dates in each iteration?
var ind=start.getMonth();
var thisMonthDates = [];
while(ind<=yearDifference){
for (var k = 0; k < selectedArrayLength; k++) {
if (new Date(selected[k]).getMonth() == monthIndex[ind]) {
thisMonthDates = selected[k];
//console.log(new Date(thisMonthDates[k]));
}
}
for(var eachDt=0; eachDt<thisMonthDates.length; eachDt++) {
//code for highlighting the dates
}
ind++;
}
Following is the selected[] array contents. And thisMonthDates[] is an empty array before the loop.
selected = [Date 2015-01-06T19:00:00.000Z,
Date 2015-01-13T19:00:00.000Z,Date 2015-01-20T19:00:00.000Z,Date 2015-01-27T19:00:00.000Z,
Date 2015-02-03T19:00:00.000Z,Date 2015-02-10T19:00:00.000Z,Date 2015-02-17T19:00:00.000Z,
Date 2015-02-24T19:00:00.000Z,Date 2015-03-03T19:00:00.000Z,Date 2015-03-10T19:00:00.000Z,
Date 2015-03-17T19:00:00.000Z,Date 2015-03-24T19:00:00.000Z,Date 2015-03-31T19:00:00.000Z,
Date 2015-04-07T19:00:00.000Z,Date 2015-04-14T19:00:00.000Z,Date 2015-04-21T19:00:00.000Z,
Date 2015-04-28T19:00:00.000Z,Date 2015-05-05T19:00:00.000Z,Date 2015-05-12T19:00:00.000Z,
Date 2015-05-19T19:00:00.000Z];
selectedandthisMonthDateslook like before the loop?