I have a bidimensional array like this:
let test2d = [
["foo", "bar"],
["baz", "biz"]
]
If I want to convert this 2D array into 1D array (not alternating their values), I can do it on two ways:
First way:
let merged = test2d.reduce( (prev, next) => prev.concat(next) )
console.log(merged) // ["foo", "bar", "baz", "biz"]
Second way:
let arr1d = [].concat.apply([], test2d)
console.log(arr1d) // ["foo", "bar", "baz", "biz"]
Question: How can I get a 1D array but with their values alternated? I mean like this:
["foo", "baz", "bar", "biz"]