i am trying to get specific week(such as saturday) days collection from my mongodb. here is the example DB collection
var array2 = [
{
"_id": "1",
"start": "2016-08-23T16:00:00.000Z",
},
{
"_id": "2",
"start": "2016-08-26T21:00:00.000Z",
},
{
"_id": "3",
"start": "2016-08-23T16:10:00.000Z",
}];
javascript week reference to get Saturday entry i run a map, and here is the code
array2.map(function(object){
var newObject = {};
var nedatee = new Date(object.start);
var weekday = nedatee.getDay();
if (weekday===6) {
newObject['start'] = true;
}
return newObject;
});
the output is
[ {}, {'start':true}, {}]
i dont want the empty object in my array, and i dont want to manually remove it, is there any smarted way? how can i make good use of reduceRight ? all i want is
[{'start':true}]
javascript map reference if you need