Symmetric Difference: Missing Test Case`

I just thought it was worth noting that the tests FCC runs for Symmetric Difference are missing an important case (found this out when I got feedback on my algorithm). You can write a function that will work for all of FCC’s examples and still miss cases like the following:

A = [1,2,2,5]
B = [3,6]

I wrote a program that dumped both arrays together and then eliminated all values that had duplicates, and it fails that test. It works if you assume both arrays are formatted as sets with no repeating entries, but not if you think of them as what they actually are, arrays. So I just thought that was interesting and worth throwing out there. (If you’re curious about my own code I’ll put it below.)

So moral of the story: don’t make the same mistake I did.

function diffArray(arr1, arr2) {
var newArr = arr1.concat(arr2);
newArr = newArr.filter(function (value, index, array) {
elOut = array.slice(0,index).concat(array.slice(index+1,array.length));
return elOut.indexOf(value) == -1;
return newArr;

Please use the [spoiler] and [/spoiler] tags to surround complete solutions like this.

Since you brought up that the missing test case, see if you can write a solution that would even handle the duplicate element example you mention above.

Thanks – sorry about not using the right tags. Thanks for fixing that.