Skip to content

Instantly share code, notes, and snippets.

@eday69
Last active June 15, 2018 17:58
Show Gist options
  • Save eday69/facdda36018c12ff51134fcc41ddc94b to your computer and use it in GitHub Desktop.
Save eday69/facdda36018c12ff51134fcc41ddc94b to your computer and use it in GitHub Desktop.
freeCodeCamp Intermediate Algorithm Scripting: 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.
// Note
// You have to use the arguments object.
function destroyer(arr) {
// Remove all the values
const args = Array.from(arguments);
let theList=args.slice(1);
return args[0].filter(item => !theList.includes(item));
}
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