Last active
October 15, 2015 04:27
-
-
Save platypusrex/6add635112804a82cf43 to your computer and use it in GitHub Desktop.
Javascript - Take 2 or more arrays and return an array of unique value in the original order
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 unite(arr1, arr2, arr3) { | |
return Array.from(arguments).reduce(function(a, b){ | |
return a.concat(b).filter(function(val,pos,arr){ | |
return arr.indexOf(val) === pos; | |
}); | |
}); | |
} | |
unite([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