2

I have an array

arr = [
[1,2,3],
[4,5,6],
[7,8,9]
]

I want to remove the array that contains the element 4. Here it would remove 4,5,6. So it'd be arr = [[1,2,3],[7,8,9]];

I tried a for loop but I get 0. So I read this Remove items from array with splice in for loop but it didn't work. It removed the first number instead.

Community
  • 1
  • 1
hammies
  • 1,344
  • 2
  • 22
  • 46

1 Answers1

6
arr.filter(function(v) {
   return !v.includes(4);
});
Yuriy Yakym
  • 3,616
  • 17
  • 30