Forum Discussion

shreegeet's avatar
shreegeet
New Contributor II
6 years ago

Traverse through an array

Hi,

I have data in array format in two different streams , I want to check whether the array elements of the 1st stream are present in the 2nd stream or not. How should I do that?

  1. [“1001”,“1003”]

  2. [“1001”,“1002”,“1003”,“1004”]

I have tried using map function after Merge Join and I am able to access the elements of any stream but cannot compare it with the elements of second stream. Can you please suggest how can I achieve this.

Regards,
Shreegeet

2 Replies

  • alchemiz's avatar
    alchemiz
    Contributor III

    array1.filter((x,y,z)=> array2.indexOf(x) == -1).length > 0 ? ‘An element/s in array1 but not in array2’ : ‘All elements in array1 is in array2’