Skip to content

Instantly share code, notes, and snippets.

@bflannery
Created December 27, 2016 14:48
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 bflannery/78368e6f44ddf5053bd24ee4dee4530e to your computer and use it in GitHub Desktop.
Save bflannery/78368e6f44ddf5053bd24ee4dee4530e to your computer and use it in GitHub Desktop.
Remove all elements from the initial array that are of the same value as these arguments.
// Remove all elements from the initial array that are of the same value as these arguments.
function destroyer(arr) {
let argArr = arr.slice.call(arguments);
argArr.splice(0,1);
return arr.filter((element) => {
return argArr.indexOf(element) === -1;
});
}
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3));
console.log(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3));
console.log(destroyer(["tree", "hamburger", 53], "tree", 53));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment