It's a bit fuzzy for me, but I'm trying to create a simple function that takes an array and some arguments and removes the arguments from the array.
For example if I have an array such as [1,2,3,4] and the arguments 2,3 it would return [1,4] as a result.
This is what I have so far:
const removeFromArray = (arr) => {
let args = Array.from(arguments);
return arr.filter(function (item) {
!args.includes(item);
});
}
It doesn't work though. It works if I want to remove all the items from the array, but doesn't if I only go for specific ones.
How can I make this work so that it works even if I'm supplying an argument that is not part of the array (I want it to ignore those) and also if I have strings in the array as well?
Thanks in advance!