I have an array of objects in my javascript which has data like
const data = [
{
base: {
storms: {
description: "Edíficio 100.000€ | Conteúdo 50.000€ | Franquia 150€",
included: true,
__typename: "PackageValue",
},
fire: {
description: "Edíficio 100.000€ | Conteúdo 50.000€ | Sem franquia",
included: true,
__typename: "PackageValue",
},
solar: {
description: "5.000€ | Franquia 150€",
included: true,
__typename: "PackageValue",
},
__typename: "HomeBase",
},
},
{....},
{.....}
];
containing various objects inside this array,
so in my file i defined some static keys as
export const HOMEPACKAGES = {
mainInfo : ['base.storms', ///so that when i loop over array above i can use this string to access values for eg - data[i].base.storms
'base.fire',
'base.flooding',
'base.theft'
]
}
then in order to show the product to the user i am looping over my array of object
data.map((item,index)=><div>"Some content here"</div>)
now my issue is as soon as i start looping and get my first item from "data" array, how do i grab the value like
item.base.storms?
i tried it like
data.map((item,index)=>HOMEPACKAGES.mainInfo.map((headerKey,index)=><div>{item.headerKey.included}</div>)) //in order to get item.base.storms.included
but got error