So I have this issue.
I have this object containing 3 arrays...
items = {
a: ['STRAWBERRY', 'PEANUT'],
b: ['John', 'Doe', 'Scarface'],
c: ['Circle', 'Square', 'Triangle', 'Rectangle'],
}
I need this output:
[
'STRAWBERRY',
'John',
'Circle',
'PEANUT',
'Doe',
'Square',
'Scarface',
'Triangle',
'Rectangle'
]
NOTE THAT THE OUTPUT INTERLEAVES BETWEEN EACH VALUE OF EACH ARRAY OF THE 'ITEMS' OBJECT
I tried to figure out a good way to do that kind of "merge" but I can only think in giant methods with tons and tons of code and whiles.
Is there a fast and optimized way to do this?
P.S.: I can use any framework.
EDIT Using @evillive answer I was able to adapt to my code in Coffee Script
RESOLUTION USING COFFEE SCRIPT
result = []
col = -1
loop
col++
run = false
for k of Items
Items[k][col] and (run = result.push(Items[k][col]))
unless run
break
console.log result