Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sortedUnion(){
- // first put arguments into array
- return Array.from(arguments)
- // now merge all arrays into a single array through 'reduce' function
- .reduce(function(arrA,arrB){
- return arrA.concat(arrB);
- }, [])
- // now remove duplicates using 'filter' function
- .filter(function(value, index, arr){
- return arr.indexOf(value) === index;
- })
- }
Add Comment
Please, Sign In to add comment