I would like to add/append value filtering based on unique dates and append the value inside latitude value which is inside another object coordinates.
Input:
data = [
{
latitude: "1.2",
longitude: "2.2",
address: "sadsdasd",
time_stamp: "04 June 2022 11.23 am"
},
{
latitude: "1.5",
longitude: "2.5",
address: "sadsdasd",
time_stamp: "04 June 2022 11.55 am"
},
{
latitude: "1.7",
longitude: "2.7",
address: "sadsdasd",
time_stamp: "05 June 2022 11.57 am"
},
{
latitude: "1.8",
longitude: "2.8",
address: "sadsdasd",
time_stamp: "05 June 2022 11.58 am"
},
{
latitude: "1.9",
longitude: "2.9",
address: "sadsdasd",
time_stamp: "06 June 2022 11.59 am"
}
]
Output:
[
{
"date": "04-06-2022",
"coordinates": [{
"latitude": "1.2",
"longitude": "2.2"
},
{
"latitude": "1.5",
"longitude": "2.5"
}
]
},
{
"date": "05-06-2022",
"coordinates": [{
"latitude": "1.7",
"longitude": "2.7"
},
{
"latitude": "1.8",
"longitude": "2.8"
}
]
}, {
"date": "06-06-2022",
"coordinates": [{
"latitude": "1.9",
"longitude": "2.9"
}]
}
]
It should filter based on condition and append the value.