Last active
November 28, 2015 19:12
-
-
Save justincorrigible/1cc45b23c14e40d87739 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/hallaathrad 's solution for Bonfire: Seek and Destroy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bonfire: Seek and Destroy | |
// Author: @hallaathrad | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20var%20taBort%20%3D%20Array.prototype.slice.call(arguments%2C1)%3B%0A%20%20return%20arr.filter(function(obj)%7Breturn%20(taBort.indexOf(obj)%3C0)%3B%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) { | |
var taBort = Array.prototype.slice.call(arguments,1); | |
return arr.filter(obj => taBort.indexOf(obj)<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
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. ES6 <3