Skip to content

Instantly share code, notes, and snippets.

@efarioli
Created November 27, 2016 12:56
Show Gist options
  • Save efarioli/2d4db8d492ef80bc3b458df515422e15 to your computer and use it in GitHub Desktop.
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.
//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