Data Transformation

Joined
Jun 12, 2021
Messages
1
Reaction score
0
I have data coming from a react-select custom component that looks like this:-

[
[
{label: “name1”, value: “name1”, Group_Number: “Group1”}
{label: “name2”, value: “name2", Group_Number: “Group1”}
]
[
{label: “name3”, value: “name3”, Group_Number: “Group2”}
{label: “name4”, value: “name4”, Group_Number: “Group2”}
]
]
The outer array length is dynamic and so is the inner array length, based on values that the user selects. How do I transform this in this format.

[
{
Group_Number: “Group1”,
Players: [
“name1”,
“name2”
]
},
{
Group_Number: "Group 2",
Players: [
“name3”,
“Name4”
]
}
]

tried all techniques like foreach, map, reduce etc etc...Not able to crack it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top