Answers for "filtering array of friends javascript"

0

filtering array of friends javascript

var namesArray = [
  { name: 'John', friend: 'Steve', brother: 'Jeff', sister: 'Karen' },
  { name: 'Sarah', friend: 'Joan', brother: 'Marvin', sister: 'Diana' },
  { name: 'Morris', friend: 'Tanya', brother: 'Mike', sister: 'Lisa' },
  { name: 'Brian', friend: 'Tim', brother: 'Andrew', sister: 'Tanya' },
];

var tanyaOnly = namesArray.filter(e => Object.values(e).indexOf("Tanya") > -1);

console.log(tanyaOnly);
Posted by: Guest on November-18-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language