Hey everyone, I'm facing a little problem here.
Basically, I have this object that contains 3 arrays...
items = {
a: ['STRAWBERRY', 'PEANUT'],
b: ['John', 'Doe', 'Scarface'],
c: ['Circle', 'Square', 'Triangle', 'Rectangle'],
}
What I'm looking for is this specific output:
[
'STRAWBERRY',
'John',
'Circle',
'PEANUT',
'Doe',
'Square',
'Scarface',
'Triangle',
'Rectangle'
]
IMPORTANT NOTE: THE OUTPUT NEEDS TO INTERLEAVE BETWEEN EACH VALUE OF THE ARRAYS INSIDE THE 'ITEMS' OBJECT
I've been trying to come up with an efficient way to achieve this without having to write a massive amount of code full of loops.
Does anyone know of a quick and optimized solution for this?
P.S.: I am open to using any available framework.
UPDATE Thanks to @evillive's response, I managed to adapt the approach into CoffeeScript
SOLUTION 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