Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 12afaelPereira/36c83c45c66c4e9a8e888735ca97813d to your computer and use it in GitHub Desktop.
Save 12afaelPereira/36c83c45c66c4e9a8e888735ca97813d to your computer and use it in GitHub Desktop.
function uniteUnique(arr) {
let myArr = [];
for(let i=0; i<arguments.length; i++){
for(let j=0; j< arguments[i].length; j++){
myArr.push(arguments[i][j]);
}
}
myArr = [...new Set(myArr)]
return console.log(JSON.stringify(myArr));
}
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
uniteUnique([1, 2, 3], [5, 2, 1])
uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment