The console says arr1 is not a function!

function union(arr1, arr2, arr3) {//1
 arr1 = arr1.concat(arr2).concat(arr3);
 console.log("concatenation of arr1", arr1, '\n');
  arr1 = arr1.sort();
  console.log("arr1 good ordered", arr1, '\n');
  for(i = arr1.length - 1; i > 0; i --) {//2

        for(j = i -1; j > 0; j --) {//3
      if(arr1[i] == arr1(j)) {//4
          arr1 = arr1.splice(i, 1);
         console.log("arr1 spliced", arr1);

      }//4c
    }//3c
  }//2c
  return arr1;
}//1c

union([1, 3, 2], [5, 2, 1, 4], [2, 1]);

This type of error occurs many times and I don't definitely understand what is the problem. I know that there as methods that change arrays as splice, and some methods dont change arrays but make new arrays on the basis of other array as slice of array.
But here I give up.

@JamesCherrill
Thank's ):
I also modified "arr1 = arr1.splice(i, 1)" by" arr1.splice(i, 1") and continue to try.

Edited 1 Year Ago by kouty

This question has already been answered. Start a new discussion instead.