How would you merge these two functions into a single more generic function?
// concatStringsFromObject :: Object, Array, String -> Strings
const concatStringsFromObject = (o = {}, a = [], j = ' ') => {
return a.filter( x => o.hasOwnProperty(x) )
.map( x => o[x] )
.join(j);
};
// concatStringsFromArrayOfObject :: Array, String, String -> Strings
const concatStringsFromArrayOfObject = (a = [], s = '', j = ', ') => {
return a.filter( x => x.hasOwnProperty(s) )
.map( x => x[s] )
.join(j);
};