Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save anonymous/34d073748f48e32c4746 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/34d073748f48e32c4746 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/mushfick 's solution for Bonfire: Seek and Destroy
// Bonfire: Seek and Destroy
// Author: @mushfick
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20%2F%2F%20Remove%20all%20the%20values%0A%20%20var%20args%20%3D%20Array.prototype.slice.call(arguments).splice(1)%3B%0A%20%20%0A%20%20return%20arr.filter(function(val)%20%7B%0A%20%20%20%20return%20args.indexOf(val)%20%3D%3D%3D%20-1%3B%0A%20%20%7D)%3B%0A%7D%0A%0Adestroyer(%5B1%2C%202%2C%203%2C%201%2C%202%2C%203%5D%2C%202%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
// Remove all the values
var args = Array.prototype.slice.call(arguments).splice(1);
return arr.filter(function(val) {
return args.indexOf(val) === -1;
});
}
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