@anonymous/

BoringStaleAcouchi

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function unite(arr1, arr2, arr3) {
  
  var sorted_union = [arr1], set2 = [], set3 = []; 
  // create uniion of 2 arrays
    arr2.forEach(function(number){
      if (arr1.indexOf(number) === -1) {
        set2.push(number);
      } 
    });
                 
    sorted_union.push(set2); 
    
    console.log(sorted_union) ; 
    console.log(sorted_union.indexOf([5,4])); 
    
    /*
    arr3.forEach(function(number){
      if (sorted_union.indexOf(number) === -1) {
        set3.push(number);
      }  
  
    });

  sorted_union.push(set3); 
  */
  return sorted_union; 
}

unite([1, 2, 3], [5, 2, 1, 4], [2, 1]);
Native Browser JavaScript