Answers for "javascript find matching elements in two arrays"

1

javascript find matching elements in two arrays

const intersection = array1.filter(element => array2.includes(element));
Posted by: Guest on June-25-2020
1

javascript find matching elements in two arrays

let firstArray = ["One", "Two", "Three", "Four", "Five"];
let secondArray = ["Three", "Four"];

let map = {};
firstArray.forEach(i => map[i] = false);
secondArray.forEach(i => map[i] === false && (map[i] = true));
let jsonArray = Object.keys(map).map(k => ({ name: k, matched: map[k] }));
Posted by: Guest on May-20-2020

Code answers related to "javascript find matching elements in two arrays"

Code answers related to "Javascript"

Browse Popular Code Answers by Language