Answers for "other than .includes to compare one value from one array and other value inside array"

2

javascript find matching elements in two arrays

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

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 "other than .includes to compare one value from one array and other value inside array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language