So i have an array with objects which has the basic information such as:
var data = [{
"id": 31737,
"mobile": "123456",
"name": "Jack",
"time": "2019-12-15 13:52:43"
},
{
"id": 31737,
"mobile": "123456",
"name": "Jack",
"time": "2019-12-14 12:00:00"
},
{
"id": 31737,
"mobile": "123456",
"name": "Jack",
"time": "2019-12-14 09:15:05"
},
{
"id": 88991,
"mobile": "123456",
"name": "Mike",
"time": "2019-12-15 12:10:43"
},
{
"id": 88991,
"mobile": "123456",
"name": "Mike",
"time": "2019-12-15 10:52:43"
},
{
"id": 88991,
"mobile": "123456",
"name": "Mike",
"time": "2019-12-14 09:52:43"
}
]
As you can see, the array stores the arrival time of each person. Same person has different arrival times, I need to make a function that returns new array, which stores each person's the latest arrival time(record) only. For returning the latest date, i found this answer answer, but can't really figure out how i should do in this situation, where similar id
(or person) appears for couple times. How should i iterate so i can know that this time
is Mike's arrival time and not Jack's. Thank you.