info = {
start: 1,
data: [
{
name: 'Maria',
date: '2020-02-15
},
{
name: 'Paula',
date: '2020-06-10
},
{
name: 'Eva',
date: '2020-12-05
},
{
name: 'Sophia',
date: '2021-03-21
}
],
totalRecords: 25
}
I am attempting to filter the information to show only the most recent date, which is 2021-03-21
.
This is what I have tried:
response['data']['data'] = response['data']['data'].filter(item => {
return item['date'] > '2021-03-21';
});
However, it is not yielding the desired result.
The expected outcome should resemble this
info = {
start: 1,
data: [
{
name: 'Sophia',
date: '2021-03-21'
}
],
totalRecords: 25
}