function getSymDifference(a, b) {
var aa = a.slice(),
bb = b.slice(),
result = [],
i, j;
for (i = 0; i < aa.length; i++) {
j = bb.indexOf(aa[i]);
if (j === -1) {
result.push(aa[i]);
} else {
bb.splice(j, 1);
}
}
return result.concat(bb);
}
console.log(getSymDifference(["diorite", "andesite", "grass", "dirt", "pink wool", "dead shrub"], ["diorite", "andesite", "grass", "dirt", "dead shrub"])); // ["pink wool"]
console.log(getSymDifference([1, "calf", 3, "piglet"], [7, "filly"])); // [1, "calf", 3, "piglet", 7, "filly"]
console.log(getSymDifference([], ["snuffleupagus", "cookie monster", "elmo"]));
console.log(getSymDifference([1, 2, 3, 5], [1, 2, 3, 4, 5]));
.as-console-wrapper { max-height: 100% !important; top: 0; }