I have two set of objects
const obj1 = {
men: {
value: "men",
attribute_label: "Men",
type: "select",
attribute_options: {
1: { label: "infant", value_string: "1" },
2: { label: "baby", value_string: "2" }
}
},
women: {
value: "women",
attribute_label: "Women",
type: "select",
attribute_options: {
1: { label: "infant", value_string: "1" },
2: { label: "baby", value_string: "2" }
}
},
kids: {
value: "kids",
attribute_label: "Kids",
type: "select",
attribute_options: {
7: { label: "infant", value_string: "1" },
8: { label: "baby", value_string: "2" }
}
}
};
and set2
const obj2 = {
men: { code: "men", title: "Men" },
women: { code: "men", title: "Men" }
};
I want to compare both the set of object and if key is same i want to get the result as new object
const resultobj = {
men: {
value: "men",
attribute_label: "Men",
type: "select",
attribute_options: {
1: { label: "infant", value_string: "1" },
2: { label: "baby", value_string: "2" }
}
},
women: {
value: "women",
attribute_label: "Women",
type: "select",
attribute_options: {
1: { label: "infant", value_string: "1" },
2: { label: "baby", value_string: "2" }
}
}
};
And i want to display label from result obj and show label inside option . I have label in Men and inside option i have other 2 label boy and guy. Same in the case of Women. So i want to display the value inside option as well. Example format i have mentioned.
Men
boy Guy
Women
Lady Girl
See Question&Answers more detail:
os