I will go straight to the point, so here is what I have:
const someObj = {
one: [
{
id: 123,
text: "lalala"
},
{
id: 456,
text: "lalala2"
},
{
id: 789,
text: "lalala3"
}
],
two: [
{
id: 111,
text: "text random"
},
{
id: 222,
text: "text random2"
},
{
id: 333,
text: "text random3"
}
]
};
and this is what I need to have:
const someOtherObj = {
111: {
id: 111,
text: "text random"
},
222: {
id: 222,
text: "text random2"
},
333: {
id: 333,
text: "text random3"
},
123: {
id: 123,
text: "lalala"
},
456: {
id: 456,
text: "lalala2"
},
789: {
id: 789,
text: "lalala3"
}
};
I know this can be achieved without million loops, just I can't think of any smart solution. :/ So, maybe someone can help me to solve this puzzle? :)
Thanks :)