I have a JSON that is returning Objects inside of an array.
I'm using angular.forEach to iterate the data. Each object has a date to which I would like to compare with the next object in the list.
How could this be done?
The snippet below is returning all the dates, I would like to check if the next entry is the same date as the previous. If it is not then compare the two values with Moment.js
So the first [0] and second [1] have the same date, however the third date [2] has "2015-01-03" I need to catch this and compare the two values.
Your help is greatly appreciated!
$scope.my_data = [
{
date: "2015-01-02"
},
{
date: "2015-01-02"
},
{
date: "2015-01-03"
},
];
angular.forEach($scope.my_data, function(value1, key1) {
var missing_days = value1.date;
console.log('missing days', missing_days);
});