Skip to content

Instantly share code, notes, and snippets.

@mmloveaa
Last active December 29, 2017 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mmloveaa/6093f6141b19b70677b0ace85a83d20d to your computer and use it in GitHub Desktop.
Save mmloveaa/6093f6141b19b70677b0ace85a83d20d to your computer and use it in GitHub Desktop.
5/3 Seek and Destroy
You will be provided with an initial array (the first argument in the destroyer function),
followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.
function destroyer(arr) {
var myArguments = [];
for (var i=1; i<arguments.length; i++){
myArguments.push(arguments[i]);
}
return arr.filter(function(remove){
return myArguments.indexOf(remove) < 0;
});
}
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