I have an array with dates and I want to take the last value from array for each month. How can I do that? I have this code:
for (var i = 0; i < vm.openDatesToSave.length; i++) {
var c = vm.openDatesToSave[i].getMonth();
for (var j = i+1; j < vm.openDatesToSave.length; j++) {
var d = vm.openDatesToSave[j].getMonth();
if (d === c) {
a.push(vm.openDatesToSave[j]);
}
}
}
For example, I want to take Jan 09, Feb 06 and Mar 14.

getMontha string or number or Date object?