My function takes an array of arrays and returns the merged array without duplicates
function mergeArrayOfPrimitives<T>(
primitiveArraysTobeMerged: Array<Array<T>>
): Array<T> {
const merged: Array<T> = [];
primitiveArraysTobeMerged.forEach((primitiveArray: Array<T>) =>
[...merged].concat([...primitiveArray])
);
return [...new Set([...merged])];
}
But when I test it on typescript
playground with below inputs, it returns []
instead of ['CORE - AGILE']
console.log(mergeArrayOfPrimitives([[], ['CORE - AGILE']])); ==> [LOG]: []