Concat strings from Object or Array How would you merge these two functions into a single more generic function?

// concatStringsFromObject :: Object, Array, String -&gt; Strings
const concatStringsFromObject = (o = {}, a = [], j = ' ') =&gt; {
    return a.filter( x =&gt; o.hasOwnProperty(x) )
            .map( x =&gt; o[x] )
            .join(j);
};

// concatStringsFromArrayOfObject :: Array, String, String -&gt; Strings
const concatStringsFromArrayOfObject = (a = [], s = '', j = ', ') =&gt; {
    return a.filter( x =&gt; x.hasOwnProperty(s) )
            .map( x =&gt; x[s] )
            .join(j);
};
The best functions have functional cohesion,
meaning they do one thing, and do it well.
I don't see a reason to merge these functions, and I don't see how that would be an improvement.

The first function takes Object, Array, String arguments,
the second one takes Array, String, String.
If you need something that works with both Object and Array,
then you can make it check the underlying type of its parameter,
and delegate to the appropriate method.
So it will be a 3rd function, using the other two under the hood.


  I need to be easy to test.


There's nothing special here to make testing hard.
You can either test the two main worker methods directly,
or test everything through the 3rd method.