My mind is boggled, maybe because i've been stuck on this issue for a bit.
I have an array (redacted for readability):
variants = [
{title: 'color', children: [{title: 'red'}, {title: 'blue'}]
{title: 'size', children: [{title: 'large'}]
]
But need the following output:
variants = [
'color/red/size/large',
'color/blue/size/large',
]
or if the initial array is:
variants = [
{title: 'color', children: [{title: 'red'}, {title: 'blue'}]
{title: 'size', children: [{title: 'large'}, {title: 'medium'}]
]
the new array would be:
variants = [
'color/red/size/large',
'color/blue/size/large',
'color/red/size/medium',
'color/blue/size/medium',
]
question from:
https://stackoverflow.com/questions/65865752/how-would-you-reduce-this-array-read-description-for-more-info 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…