Suppose i have a array like this:
const HeaderData = [
{
header: {
title: "How you'll benefit",
detail:
"We create this goals to help you recover from your recent surgery. Slowly increase your physical strength is an important part of recovery. With this plan, you will be back to normal in no time. You got this!",
},
xyz: {
title: "dsdsdas",
},
},
{
mainData: [
{
detail: "4/1/2021",
},
{
detail: "Jennifer. 0",
},
{
detail: "4/1/2021",
},
{
detail: "In progress",
},
],
},
{
activity: [
// title
{
activity1: "Take the stairs",
activity2: "5 Sets of Sit-Ups",
activity3: "3 sets of Push-Up",
activity4: "Weight-lifting",
},
// notSatisfied
{
activity1: 5,
activity2: 3,
activity3: 7,
activity4: 3
},
//neutral
{
activity1: 0,
activity2: 2,
activity3: 2,
activity4: 3,
},
//satisfied
{
activity1: 2,
activity2: 5,
activity3: 1,
activity4: 0,
},
],
},
]
I only know how to get data in a child if they have same name, for example in my array is activity1 or title, using map() because it have the same name, but problem is , they very confusing and easy to misunderstand ,if i want to get all data in a child , how can i do that. For example, if i change above array to this
const HeaderData = [
{
header: {
title: "How you'll benefit",
detail:
"We create this goals to help you recover from your recent surgery. Slowly increase your physical strength is an important part of recovery. With this plan, you will be back to normal in no time. You got this!",
},
xyz: {
title: "dsdsdas",
},
},
{
mainData: [
{
title: "Created On",
detail: "4/1/2021",
},
{
title: "Created By",
detail: "Jennifer. 0",
},
{
title: "Started",
detail: "4/1/2021",
},
{
title: "Completed",
detail: "In progress",
},
],
},
{
activityName: [
{
title: "Take the stairs",
notSatisfied: 5,
neutral: 0,
satisfied: 2,
},
{
title: "5 Sets of Sit-Ups",
notSatisfied: 3,
neutral: 2,
satisfied: 5,
},
{
title: "3 sets of Push-Up",
notSatisfied: 7,
neutral: 3,
satisfied: 1,
},
{
title: "Weight-lifting",
notSatisfied: 3,
neutral: 2,
satisfied: 0,
},
],
},
]
It much more clear now, in my opinion but now i'm stuck, i don't khow how to get data from first elemet from mainData
{
title: "Take the stairs",
notSatisfied: 5,
neutral: 0,
satisfied: 2,
},
If i want to get ALL this data at once through map(), how can i do that? I only know if they have the same name
Please help, thank a lot