Here is the input data provided:
data = [
{ name: "John Cena", groupName: "WWE" },
{ name: "Nandini", groupName: null },
{ name: "Rock", groupName: "WWE" },
{ name: "Vinay", groupName: null },
{ name: "Rey Mesterio", groupName: "WWE" },
{ name: "Gokul", groupName: "FSD" },
{ name: "Rohitha", groupName: "FSD" }
];
The desired output format should be as follows:
requiredFormat = [
{ name: "FSD", value: ["Gokul", "Rohitha"] },
{ name: "WWE", value: ["John Cena", "Rock", "Rey Mesterio"] },
{ name: null, value: ["Nandini", "Vinay"] }
];