I have this arrray of arrays: [ [ 'RF1', ' FF1' ], [ 'FF1' ], [ 'FF1' ] ]
I am trying to destructure and reduce down to unique values ['FF1', 'RF1']
(order doesn't matter).
I tried something I found here, with the following function.
const merge = (...arrays) => {
let jointArray = [];
arrays.forEach(arr => {
jointArray = [...jointArray, ...arr];
});
console.log('jointArray', jointArray);
const unique = jointArray.filter((item, index) => jointArray.indexOf(item) === index);
console.log('unique', unique);
return unique;
}
let arr = [ [ 'RF1', ' FF1' ], [ 'FF1' ], [ 'FF1' ] ];
merge(arr);
and it returns exactly what I am putting in, what am I missing here?
jointArray [ [ 'RF1', ' FF1' ], [ 'FF1' ], [ 'FF1' ] ]
unique [ [ 'RF1', ' FF1' ], [ 'FF1' ], [ 'FF1' ] ]