Monday, April 23, 2018

Find the items that two arrays have in common in TypeScript using .filter!

let yin = [13, 42, 69];
let yang = [42, 69, 86];
let venn = yin.filter(y => {
   if (yang.indexOf(y) > -1) return true;
});
console.log(venn);

No comments:

Post a Comment