I’m using Lodash to make manipulating objects easier. I have an object with three nested objects inside. I’d like to iterate through these, concatenating all of their respective children together in all possible combinations, whilst only using one per list.
My object looks like this:
{
"list_1": {
"1": ".cat-3",
"2": ".cat-5",
"3": ".cat-7"
},
"list_2": {
"1": ".eyes-blue",
"3": ".eyes-brown"
},
"list_3": {
"1": ".jazz",
"2": ".commercial",
"3": ".hip-hop"
}
}
The output I’d like to get is:
.cat-3.eyes-blue.jazz
.cat-3.eyes-blue.commercial
.cat-3.eyes-blue.hip-hop
The order isn't crucial. What's crucial is that only one value from each list_
object is used in the string. So this, for example, would be fine:
.eyes-blue.jazz.cat-3
.eyes-blue.cat-3.commercial
.hip-hop.eyes-blue.cat-3
And some more examples:
.cat-3.eyes-brown.jazz
.cat-5.eyes-brown.hip-hop
.cat-7.eyes-blue.hip-hop