Created
November 2, 2020 23:55
-
-
Save heanfig/7345059d1b8cf303773dbe75c4ebb185 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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].sort((a,b)=>a-b) | |
},[]); | |
} | |
console.log(sym([3, 3, 3, 2, 5], [2, 1, 5, 7], [3, 4, 6, 6])); //[1, 4, 6, 7] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment