Created
December 27, 2016 14:48
-
-
Save bflannery/78368e6f44ddf5053bd24ee4dee4530e 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
// Remove all elements from the initial array that are of the same value as these arguments. | |
function destroyer(arr) { | |
let argArr = arr.slice.call(arguments); | |
argArr.splice(0,1); | |
return arr.filter((element) => { | |
return argArr.indexOf(element) === -1; | |
}); | |
} | |
console.log(destroyer([1, 2, 3, 1, 2, 3], 2, 3)); | |
console.log(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)); | |
console.log(destroyer(["tree", "hamburger", 53], "tree", 53)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment