-2

I have an array like this:

let arr = ['liverpool', 'arsenal', 'man utd', 'chelsea', 'tottenham', 'crystal palace', 'madrid', 'barcelona'];

and I want to remove items, let's say 'arsenal' and 'chelsea', but this needs to be dynamic.

I have tried the following, where items is an array but unfortunately it didn't work:

function removeItems(items) {
   arr.filter(item => {
      return !arr.includes(items)
   });
}

removeItems(['arsenal', 'chelsea']);
T.J. Crowder
  • 879,024
  • 165
  • 1,615
  • 1,639
peter flanagan
  • 6,130
  • 13
  • 50
  • 94

1 Answers1

2

I think what you are trying to do is this:

function removeItems(items) {
   return arr.filter(item => {
      return !items.includes(item)
   });
}

const newArr = removeItems(['arsenal', 'chelsea']);
Charmy
  • 98
  • 5