Hello I have a little problem I have arrays like this:
const arrays = {
1: [c, u, g],
2: [c, u],
3: [c, u ,f],
4: [c, g],
5: [m, c, g],
6: [u, m]
}
Values in each array are unique. I would like to convert it to an object like this:
const object = {
c: {
u: {
g: {
ends: 1
},
f: {
ends: 3
}
ends: 2
},
g: {
m: {
ends: 5
}
ends: 4
}
},
u: {
m: {
ends: 6
}
}
}
Is it possible ? And if so could you give me hint, piece of code or any other type of answer I'm hard stuck here.
[m, c, g]missing from the output?ming, butmis beforec. You may have to loop 2 times, one first time to order by occurences count ?c.g.mit's also what is puzzling me