I want to remove all elements from the initial array that are of the same value as these arguments.
Ex:
destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].
destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].
Here's my code:
function takeaway(value) {
return ??
}
function destroyer(arr) {
// Remove all the values\
var args = Array.from(arguments); // args = [[1,2,3,1,2,3],2,3]
var arr1 = args.shift(); // arr1 = [1, 2, 3, 1, 2, 3]
// args = [2,3]
var filtered = arr1.filter(takeaway);
return filtered;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
If I'm not mistaken I need to pass the elements that I want to take out (the args array) into the filter function so it knows what to filter out... How would I accompish this?