Имею такой исходные данные:
const A = [
{ category: "Walls", id: "1", symbol: "Wall-Ext_102", family: "Basic Walls" },
{ category: "Walls", id: "2", symbol: "Wall-Ext_102", family: "Basic Walls" }
];
const B = [
{ category: "Window", id: "3", symbol: "Window-Ext_102", family: "Basic Window" },
{ category: "Walls", id: "4", symbol: "Wall-Other-102", family: "Other Walls" }
];
const C = [
{ category: "Walls", id: "5", symbol: "Wall-Ext_102", family: "Basic Walls" },
{ category: "Floor", id: "6", symbol: "Floor-Ext_102", family: "Basic Floor" }
];
const D = [
{ category: "Walls", id: "5", symbol: "Wall-Ext_102", family: "Basic Walls" },
{ category: "Walls", id: "6", symbol: "Wall-Ext_102", family: "Basic Walls" }
];
После получаю такой объект:
const data = [...A, ...B, ...C, ...D];
const result = data.reduce((acc, curr) => {
const {category, family, symbol, id} = curr;
acc.category[category] = acc.category[category] || {family: {}};
acc.category[category].family[family] = acc.category[category].family[family] || {symbol: {}};
acc.category[category].family[family].symbol[symbol] = acc.category[category].family[family].symbol[symbol] || {id: []};
acc.category[category].family[family].symbol[symbol].id.push(id);
return acc;
}, {category: {}});
Теперь хочу отобразить этот объект на html странице как выпадающий список. Все мои имеющиеся коды не подходят для этого. Буду очень благодарен за помощь.