Move getSymmetricDifference to helper file

This commit is contained in:
Sam Carlton 2022-06-11 17:04:21 -05:00
parent ce710b1f55
commit 79640781bc
2 changed files with 24 additions and 9 deletions

21
helpers/array.js Normal file
View file

@ -0,0 +1,21 @@
export function getSymmetricDifference (a, b) {
return [
a.filter(x => !b.includes(x)),
b.filter(x => !a.includes(x))
]
}
export function logArraysDifference (a, b) {
const [ aOnly, bOnly ] = getSymmetricDifference(a, b)
console.log( 'Missing from first list:', aOnly )
console.log( 'Missing from second list:', bOnly )
console.log( `List difference Count ${ aOnly.length } / ${ bOnly.length }`, )
return {
aOnly,
bOnly,
}
}