Created
May 26, 2019 23:35
-
-
Save 12afaelPereira/36c83c45c66c4e9a8e888735ca97813d 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 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