I have an array of students objects (Student.all) and each object has a name and a class_id.
I want to find students with same class_id and concat their names into the same object, the others remain the same. I mean, turn this:
[
{
id: 1,
name: 'Joe',
class_id: 55
},
{
id: 2,
name: 'Bill',
class_id: 55
},
{
id: 3,
name: 'Moe',
class_id: 70
},
{
id: 4,
name: 'Larry',
class_id: 80
},
{
id: 5,
name: 'Phill',
class_id: 80
}
]
Into this:
[
{
id: 1,
name: 'Joe/Bill',
class_id: 55
},
{
id: 3,
name: 'Moe',
class_id: 70
},
{
id: 4,
name: 'Larry/Phill',
class_id: 80
}
]