filtering array of friends javascript

Solutions on MaxInterview for filtering array of friends javascript by the best coders in the world

showing results for - "filtering array of friends javascript"
Daniele
14 May 2019
1var namesArray = [
2  { name: 'John', friend: 'Steve', brother: 'Jeff', sister: 'Karen' },
3  { name: 'Sarah', friend: 'Joan', brother: 'Marvin', sister: 'Diana' },
4  { name: 'Morris', friend: 'Tanya', brother: 'Mike', sister: 'Lisa' },
5  { name: 'Brian', friend: 'Tim', brother: 'Andrew', sister: 'Tanya' },
6];
7
8var tanyaOnly = namesArray.filter(e => Object.values(e).indexOf("Tanya") > -1);
9
10console.log(tanyaOnly);