const demo = {
data:[]
};
this.state.lossGroup.forEach(element => {
const z= []
this.state.selectedExposure.map((e) => {
console.log(element,e.hazard_index.type )
if (element == e.hazard_index.type) {
z.push(e.id)
}
})
demo.data.push({ element: z });
});
I just want to store the array in json file with dynamic field name in element i.e. element should be the replaced with the value from the upper loop.