1
const arr1 = ["605116", "703771", "726664", "612706", "475557", "521034", "547016"];
const arr2 = ["605116", "703771"];

arr1.map(item1 => arr2.map(item2 => (item1===item2) ? console.log(item1) : null))

result :

605116 703771

what is the condition to return the items that don't match?

expected results:

"726664", "612706", "475557", "521034", "547016" 

need to be jsx compatible

Bogdan
  • 659
  • 5
  • 8

2 Answers2

3

You can use filter and includes.

const arr1 = ["605116", "703771", "726664", "612706", "475557", "521034", "547016"];
const arr2 = ["605116", "703771"];

console.log(arr1.filter(item=>!arr2.includes(item)));
Jax-p
  • 7,225
  • 4
  • 28
  • 58
1
console.log(array1.filter(item => array2.indexOf(item) == -1));
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
ali ajouz
  • 56
  • 1
  • 2