Trying to figure out what the best practice for taking one array of objects in JS and combining the properties of it's indexes based upon a shared property value.
Basically, I have an array of users who have applied to a certain class where the class the user applied to is an array. However, every single class that the same user has applied to is its own separate index. The goal would be to combine all of a user's classes within one index (the array) instead of having duplicates.
Ex.
let someArray = [
{
name: 'Jim',
class: [
{
name: 'Sports Journalism',
field: 'Journalism'
}
]
},
{
name: 'Pam',
class: [
{
name: 'Fine Arts',
field: 'Art'
}
]
},
{
name: 'Jim',
class: [
{
name: 'Sales 101',
field: 'Business'
}
]
}
]
// something like this where we would want all of Jim's
// classes to be in one class array on just one index