Find the Symmetric Difference Issue in Test cases

Tell us what’s happening:
I have come up with the below solution which seems to be working fine in some of the test cases.
But some test case have expected results which are not correct and hence is not accepting the solution as this one:

sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return [1, 4, 5]

here 5 is clearly symmetrical and is available in all three arrays how it can be present in the result array? There are more suspicious test cases like this one.

Your code so far

function sym(...args) {
 const finalArray = [];
 const uniqueArray = [];
 const seenArray = [];   

      var arr = e.filter((v, i, a) => e.indexOf(v) === i)

        e.forEach((it) => {
            var index = finalArray.indexOf(it);
            }else {

       var index = finalArray.indexOf(item);

  return finalArray;

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:

Straight from the instructions:

… the mathematical term “symmetric difference” of two sets is the set of elements which are in either of the two sets, but not in both

implying sequential evaluation.

1 Like

Seems my approach was not correct, if sym([A], [B], [C]) is the function then it will be simplified to first solving [A] & [B] then result needs to be solved with [C] as a sequential evaluation. Thanks @lynxlynxlynx