Created
December 13, 2015 07:07
-
-
Save SerhiiLihus/4a63bea9efd3a0be01bc 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.
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: @serhiilihus | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy#?solution=function%20destroyer%28arr%29%20{%0A%20%20%0A%20%20for%20%28%20var%20i%20%3D%201%20%2C%20num%3B%20i%20%3C%20arguments.length%20%3B%20i%2B%2B%20%29%20{%0A%20%20%20%20num%20%3D%20arguments[i]%3B%0A%20%20%09arr%20%3D%20arr.filter%28filtering%29%3B%0A%20%20}%0A%20%20%0A%20%20function%20filtering%20%28%20value%20%29%20{%0A%20%20%20%20return%20value%20!%3D%3D%20num%3B%0A%20%20}%0A%20%20%0A%20%20return%20arr%3B%0A}%0A%0Adestroyer%28[1%2C%202%2C%203%2C%201%2C%202%2C%203]%2C%202%2C%203%29%3B%0A | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function destroyer(arr) { | |
for ( var i = 1 , num; i < arguments.length ; i++ ) { | |
num = arguments[i]; | |
arr = arr.filter(filtering); | |
} | |
function filtering ( value ) { | |
return value !== num; | |
} | |
return arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment