Created
August 4, 2015 19:24
-
-
Save Raincode/39b5f006a88e46451042 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unite(arr1, arr2, arr3) { | |
var unique = arr1.concat(arr2, arr3); | |
console.log("arr:"); | |
console.log(unique); | |
for (var i = 0; i != unique.length; ++i) { | |
unique.reduce(function(isDuplicate, item, index, arr) { | |
if (index != i && unique[i] === item) { | |
delete unique[index]; | |
} | |
}, 0); | |
} | |
var result = []; | |
for (var key in unique) | |
if (Boolean(unique[key])) | |
result.push(unique[key]); | |
return result; | |
} | |
unite([1, 2, 3], [5, 2, 1, 4], [2, 1]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment