I am trying to figure out how to map a new array of objects that kind of creates teams by checking each array of users and, where there is a common users, moving that entire array into a new property that also features the notebookIds in common.
I have an array of objects structured like so:
const usersByNotebooks =
[
{
"notebookId": "abc",
"users": [1, 2, 3, 4]
},
{
"notebookId": "cde",
"users": [2, 3, 4]
},
{
"notebookId": "fgh",
"users": [3, 4, 5]
},
{
"notebookId": "qqq",
"users": [33, 16, 12]
},
]
So for the above data it would become something like this:
const teams =
[
{
"notebooksOnTeam": ["abc", "cde", "fgh"],
"usersOnTeam": [1, 2, 3, 4, 5]
},
{
"notebooksOnTeam": "qqq",
"usersOnTeam": [33, 16, 12]
},
]
I am using javascript and having trouble getting the logic down.