I am facing a challenge that requires me to merge arrays of an array and produce a single array with the format
[ array[0][0], array[0][1], array[1][0], array[1][1], etc. ]
. To solve this, I utilized the `push` method within nested for-loops. However, the instructions suggest using the `concat` method instead. While I understand the syntax and functionality of the `concat` method, I am struggling to implement it to achieve the desired outcome.
Below is my current solution employing the `push` method:
function joinArrayOfArrays(arr) {
var joined = [];
for (var i = 0; i < arr.length; i++) {
for (var k = 0; k < arr[i].length; k++) {
joined.push(arr[i][k]);
}
}
return joined;
}
joinArrayOfArrays([[1, 4], [true, false], ['x', 'y']]);
// => [ 1, 4, true, false, 'x', 'y' ]
Could someone provide guidance on achieving the same result using the `concat` method?