loop array and check if value matches in js

Solutions on MaxInterview for loop array and check if value matches in js by the best coders in the world

showing results for - "loop array and check if value matches in js"
Aarón
15 Sep 2016
1var arr1 = [1, 3, 4,];
2
3var arr2 = [
4  {
5    id: 1,
6    title: 'Title 1',
7   },
8  {
9    id: 2,
10    title: 'Title 2',
11   },
12];
13
14var res = arr2.filter(i => arr1.includes(i.id));
15
16console.log(res);