Skip to content

Instantly share code, notes, and snippets.

@heanfig
Created November 2, 2020 23:53
Show Gist options
  • Save heanfig/43c041eef6c373df99e381cb5e8bff00 to your computer and use it in GitHub Desktop.
Save heanfig/43c041eef6c373df99e381cb5e8bff00 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));
const resultado = new Set([...valoresA, ...valoresB]);
return [...resultado]
},[]);
}
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6])); //[1, 7, 4, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment