Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove all elements from the initial array that are of the same value as the arguments that follow array.
function destroyer(args) {
var args = [...arguments]
, finalArray = []
, targetArray = args.shift();
finalArray = targetArray.filter(function(el) {
return args.every(function(arg) {
return ( el !== arg);
});
});
return finalArray;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.