I got this array:
[
name1,
[email protected],
[email protected],
[email protected],
name2,
[email protected],
name3,
name4,
[email protected],
[email protected],
[email protected],
[email protected],
[email protected],
]
From that array I need to parse it and create an array like the following:
[
{ dlName: < element without @ > , members: [<elements with @ >]},
{ dlName: < element without @ > , members: [<elements with @ >]},
{ dlName: < element without @ > , members: [<elements with @ >]}
]
example:
[
HR,
[email protected],
[email protected],
[email protected],
cyber,
[email protected],
[email protected],
accessibility,
accounting,
[email protected],
[email protected]
]
output:
[
{ dlName: HR , members: [[email protected],[email protected],[email protected],]},
{ dlName: cyber , members:[[email protected],[email protected],]},
{ dlName: accesibility , members: []},
{ dlName: accounting , members: [[email protected],[email protected]]}
]
How can I get this output, everything I tried does not work for me needs.
Thanks in advance