Skip to content

Instantly share code, notes, and snippets.

@heanfig
Created November 2, 2020 23:45
Show Gist options
  • Save heanfig/a04748cbc2a2bea0eb7b465e46b35173 to your computer and use it in GitHub Desktop.
Save heanfig/a04748cbc2a2bea0eb7b465e46b35173 to your computer and use it in GitHub Desktop.
function sym(...args) {
return args.reduce( (a,b,i) => {
const valoresA = a.filter(item => !b.find(aux=>aux===item));
const valoresB = b.filter(item => !a.find(aux=>aux===item));
return [...valoresA, ...valoresB]
},[]);
}
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6])); //[1, 7, 4, 6, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment