Guest User

Untitled

a guest
Oct 23rd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. function sortedUnion(){
  2. // first put arguments into array
  3. return Array.from(arguments)
  4. // now merge all arrays into a single array through 'reduce' function
  5. .reduce(function(arrA,arrB){
  6. return arrA.concat(arrB);
  7. }, [])
  8.  
  9. // now remove duplicates using 'filter' function
  10. .filter(function(value, index, arr){
  11. return arr.indexOf(value) === index;
  12. })
  13. }
Add Comment
Please, Sign In to add comment