Hey there, I'm facing a small issue with arrays similar to the ones below:
const arrays = {
1: [c, u, g],
2: [c, u],
3: [c, u ,f],
4: [c, g],
5: [m, c, g],
6: [u, m]
}
Each array contains unique values. Now, I'm looking to transform them into an object structure 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 achievable? If so, any hints, code snippets, or advice would be greatly appreciated as I'm currently stuck on this problem.