Created
September 21, 2016 03:13
-
-
Save jgresalfi/092c5f33026224da5323994443d0a868 to your computer and use it in GitHub Desktop.
Remove all elements from the initial array that are of the same value as the arguments that follow array.
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
function destroyer(args) { | |
var args = [...arguments] | |
, finalArray = [] | |
, targetArray = args.shift(); | |
finalArray = targetArray.filter(function(el) { | |
return args.every(function(arg) { | |
return ( el !== arg); | |
}); | |
}); | |
return finalArray; | |
} | |
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