I am working with an array of objects containing dates and I am looking to extract objects with the same date values into a new array. Below is the code snippet.
var posts = [
{
"userid": 1,
"rating": 4,
"mood": "happy",
"date": "2017-05-24T04:00:00.000Z"
},
{
"userid": 1,
"rating": 3,
"mood": "happy",
"date": "2017-05-24T04:00:00.000Z"
},
{
"userid": 1,
"rating": 3,
"mood": "angry",
"date": "2017-05-25T04:00:00.000Z"
},
{
"userid": 1,
"rating": 5,
"mood": "hungry",
"date": "2017-05-25T04:00:00.000Z"
}]
var may25=[];
for(i=0;i < posts.length;i++){
if(posts[i].date === posts[i].date){
may25.push(posts[i].date)
}
}