jgresalfi
9/21/2016 - 3:13 AM

Remove all elements from the initial array that are of the same value as the arguments that follow array.

Remove all elements from the initial array that are of the same value as the arguments that follow array.


function destroyer(args) {
    var args = [...arguments]
      , finalArray = []
      , targetArray = args.shift();
    finalArray = targetArray.filter(function(el) {
        return args.every(function(arg) {
            return ( el !== arg);
        });
    });
    return finalArray;
}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);