Skip to content

Instantly share code, notes, and snippets.

@arcthur
Created June 9, 2011 03:17
Show Gist options
  • Save arcthur/1015974 to your computer and use it in GitHub Desktop.
Save arcthur/1015974 to your computer and use it in GitHub Desktop.
complementary
function complementary(aArr, bArr) {
if (bArr.length === 0) {
return aArr;
}
var str = bArr.join(','),
_a = aArr.concat(bArr).sort();
_a.sort(function (a, b) {
if (a === b) {
var n = str.indexOf(a),
m = aArr.indexOf(a);
if (n != -1) {
aArr.splice(m, 1);
}
}
});
return aArr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment