Created
November 27, 2016 12:56
-
-
Save efarioli/2d4db8d492ef80bc3b458df515422e15 to your computer and use it in GitHub Desktop.
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.
This file contains hidden or 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
//javascript | |
function destroyer(arr) { | |
var argLen = arguments.length; | |
console.log(argLen); | |
var arr2 = []; | |
if (argLen <= 1) { | |
return arr; | |
} | |
for (var i = 1; i < argLen; i++) { | |
var test = arguments[i]; | |
console.log("test////" + test); | |
arr2 = arr.filter(function(el) { | |
return (el != test); | |
}); | |
arr = arr2; | |
} | |
return arr2; | |
} | |
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment