Created
February 14, 2019 15:49
-
-
Save ristaa/5d24a5a2dd83529c5498919d0df423a3 to your computer and use it in GitHub Desktop.
Concatenation of arrays and remove duplicates
This file contains 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
/* | |
* Concatenation of arrays and remove duplicates from all of them | |
* @arguments Arrays | |
*/ | |
concatArrays = (...arrays) => { | |
var children = [].concat(...arrays); | |
var returnArray = [...new Set(children)]; | |
return returnArray; | |
} | |
let arr1 = ['a', 'c', 'd']; | |
let arr2 = ['d', 'g', 'g', 'e']; | |
let arr3 = ['d', 'f', 'e', 'a']; | |
console.log(concatArrays(arr1, arr2, arr3)); // ["a", "c", "d", "g", "d", "f"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment