 # Confusing Symmetric Difference Tests

What’s happening:
One of the tests has the inputs of: [1, 2, 5], [2, 3, 5], [3, 4, 5]
With the expected output to be: [1, 4, 5]

But that doesn’t seem to make sense because 5 appears in all of the sets. Why is it included as the answer? I thought the solution would be [1,4]

Can anyone explain?

My code so far

``````function sym(args) {
let sets = Array.from(arguments);

let values = sets.reduce( (a, b) => { return a.concat(b) } );

values.sort( (a,b) => { return a-b })

console.log(values)

let filtered_values = values.filter( (value) => {
let first_index = values.indexOf(value);
if( values.indexOf(value, first_index + 1) === -1 ) { return value }
})

return filtered_values
}

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

My browser information:

My Browser User Agent is: `Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0`.

Symmetric difference is an operation that requires two sets as operands. What you see as
`[1, 2, 5] △ [2, 3, 5] △ [3, 4, 5]`

is actually

`([1, 2, 5] △ [2, 3, 5]) △ [3, 4, 5]`,

so first you’ll solve for the symmetric difference of the first two sets, then the symmetric difference of the resulting set and the last set.

1 Like

@kevcomedia, could you explain the little triangle for those that only have Liberal Arts degrees?

I.e. Me

According to the challenge instructions, the triangle is the symbol for symmetric difference

I did not RTFM, clearly. 