I know that you can remove 1 of the duplicate number out of an array but is there a way you can remove the number if they're duplicate? So far, below code is what I have. I wanted to use for loop to remove the number out of the array if they're equal, but I dont think I coded it correctly or it's not complete. I want it to return [3, 4, 5]
function sym(args) {
var array = [];
var join;
for(var i = 0; i < arguments.length; i++){
array.push(arguments[i]);
join = array[0].concat(array[1]);
}
join.sort();
for(var j = 0; j < join.length; j++) {
if(join[j] === join[j+1]) {
var removed = join.splice(j, join[j+2]);
console.log(removed);
}
}
return join;
}
sym([1, 2, 3], [5, 2, 1, 4]);