filter 2d array javascript

Solutions on MaxInterview for filter 2d array javascript by the best coders in the world

showing results for - "filter 2d array javascript"
Delfina
06 Sep 2017
1function filterByPosition(array, number, position) {
2   return array.filter(innerArray => innerArray[position - 1] !== number);
3}
4
5const items = [
6  [1, 1, 2, 4],
7  [2, 1, 4, 6],
8  [5, 6, 4, 1],
9  [1, 6, 3, 1]
10];
11
12const newItems1 = filterByPosition(items, 1, 2);
13console.log('Items1:', newItems1);
14
15const newItems2 = filterByPosition(items, 4, 3);
16console.log('Items2:', newItems2);