function combineArrays(arr1, arr2) {
    const res = [];

    if (arr1.length === 0) {
        return explodeArray(arr2);
    }
    if (arr2.length === 0) {
        return explodeArray(arr1);
    }
    arr1.forEach(x1 => {
        arr2.forEach(x2 => {
            res.push([].concat(x1, x2));
        });
    });
    return res;
}
function combineArrays(arr1, arr2) {
    const res = [];

    if (arr1.length === 0) {
        return explodeArray(arr2);
    }
    if (arr2.length === 0) {
        return explodeArray(arr1);
    }
    arr1.forEach(x1 => {
        arr2.forEach(x2 => {
            res.push([].concat(x1, x2));
        });
    });
    return res;
}
function combineArrays ( arr1 , arr2 ) { const res = [ ] ; if ( arr1 . length === 0 ) { return explodeArray ( arr2 ) ; } if ( arr2 . length === 0 ) { return explodeArray ( arr1 ) ; } arr1 . forEach ( x1 => { arr2 . forEach ( x2 => { res . push ( [ ] . concat ( x1 , x2 ) ) ; } ) ; } ) ; return res ; }
Mix two arrays such that each element of the second array is concatenated
onto each element of the first array.

For example:
combineArrays([a, [b, c]], [x, y]); // -> [[a, x], [a, y], [b, c, x], [b, c, y]]

@param   {Array} arr1 The first array to combine.
@param   {Array} arr2 The second array to combine.
@returns {Array}      A mixture of the elements of the first and second arrays.
Mix two arrays such that each element of the second array is concatenated onto each element of the first array .
Combine two arrays of arrays