Answer the question
In order to leave comments, you need to log in
How to pass an arbitrary number of arguments to a function parameter?
Good afternoon!
There is a function, the first parameter is an array, the second is a string. If the string value is in the array, it is removed from the array. But if there are more than 1 rows in the second parameter, the function processes only the last value.
I tried wrapping the filter in a for (i=0; ifunction destroyer(arr, args) {
var x = arr.filter(function(values){
return values !== args;
});
return x;
}
var z = destroyer( ["tree", "hamburger", 53], "tree", 53)
;
Answer the question
In order to leave comments, you need to log in
function delStr(ar){
var strOf = [].slice.call(arguments, 1);
return ar.filter(function(e){
return strOf.indexOf(e) < 0;
});
}
delStr(["a", "b", "c", "d"], "c", "d"); //["a", "b"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question