So I created a list of data and i need to be able to get the total number of data that has a status: ‘Open’ and display it in the console.log.
const approvals = [
{
id: 1,
member: 'Charlie Lubin',
payPeriod: 'Sun, Jan 15, 2023 - Sat, Jan 21, 2023',
duration: '45:11:36',
activity: '0.57',
status: 'Open',
submittedOn: '-',
},
{
id: 2,
member: 'Madelyn Baptista',
payPeriod: 'Sun, Jan 15, 2023 - Sat, Jan 21, 2023',
duration: '45:11:36',
activity: '0.71',
status: 'Open',
submittedOn: '-',
},
{
id: 3,
member: 'Lincoln Arcand',
payPeriod: 'Sun, Jan 15, 2023 - Sat, Jan 21, 2023',
duration: '45:11:36',
activity: '0.42',
status: 'Approved',
submittedOn: '-',
},
{
id: 4,
member: 'Ryan Botosh',
payPeriod: 'Sun, Jan 15, 2023 - Sat, Jan 21, 2023',
duration: '-',
activity: '-',
status: 'Approved',
submittedOn: '-',
},
{
id: 5,
member: 'Craig Workman',
payPeriod: 'Sun, Jan 15, 2023 - Sat, Jan 21, 2023',
duration: '45:11:36',
activity: '0.65',
status: 'Approved',
submittedOn: '-',
},
];
2
Answers
Using the filter method, you can filter your list to return a new list that has only members that pass the specified check.