I need assistance with filtering specific items and arrays within a nested array by using the methods .map
and .filter
.
Below is an example of the given array structure:
items: [
{
title: 'dashboard',
isValidateAccess: false,
},
{
title: 'reports',
isValidateAccess: true,
children: [
{
title: 'attendancesReportMenu',
isValidateAccess: true,
},
{
title: 'holidaysReportMenu',
},
{
title: 'absencesReportMenu',
isValidateAccess: true,
},
],
},
{
title: 'myDepartments',
children: [
{
title: 'inconsistencies',
isValidateAccess: true,
},
{
title: 'absences',
},
{
title: 'clocks',
isValidateAccess: true,
},
{
title: 'employees',
},
],
},
]
The goal is to remove all items/arrays where the property isValidateAccess
is set to true
. This is how the filtered array should look like:
items: [
{
title: 'dashboard',
isValidateAccess: false,
},
{
title: 'myDepartments',
children: [
{
title: 'absences',
},
{
title: 'employees',
},
],
},
]