Skip to content

Instantly share code, notes, and snippets.

@jgresalfi
Created September 21, 2016 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgresalfi/092c5f33026224da5323994443d0a868 to your computer and use it in GitHub Desktop.
Save jgresalfi/092c5f33026224da5323994443d0a868 to your computer and use it in GitHub Desktop.
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