Answers for "Comparing and Filtering two arrays"

0

Comparing and Filtering two arrays

var array1 = ['apples', 'grapes', 'oranges', 'banana'],
  array2 = ['potato', 'pears', 'grapes', 'berries', 'apples', 'oranges'];

var intersection = array1.filter(function(e) {
  return array2.indexOf(e) > -1;
});

console.log(intersection);
Posted by: Guest on May-24-2021

Code answers related to "Comparing and Filtering two arrays"

Browse Popular Code Answers by Language