The function should have one parameter, which is the truth test callback function, but any numbers of arrays can be fed as arguments, because the function will access the arguments object.
You can use the arrays below if you like for testing purposes.
var array1 = [3,5,4,3,4,5,6,35,34,56,78,345];
var array2 = [4,6,2,8,77,66,55,44,5,7,2,4];
var array3 = [3,6,9,15];
var array4 = [9,7,5,3,1];
var array5 = [44,6,5,78,234,456,678];
var array6 = [77,88,99,0,234];
var array7 = [14,65,45,87,65,45,44];
var array8 = [55,44,33,22,11];
var array9 = [3,33,333];
var array10 = [999, 871, 751];
For example, if my function was fed a callback function that tested if numbers were divisible by 4, then it would return this after feeding it all the above arrays at once:
[ 4, 4, 56, 4, 8, 44, 4, 44, 456, 88, 0, 44, 44 ]
The solution in the comments.
var filterPlus = function(test){
ReplyDeletevar filterPlusArray = [];
_.each(arguments, function(item){
_.each(item, function(val){
if(test(val)){
filterPlusArray.push(val);
}
})
})
return filterPlusArray;
}