Skip to content
Advertisement

Merge 2 arrays and keep ONLY duplicates [closed]

So, i have 2 arrays which look like this:

JavaScript

The expected result should look like this:

JavaScript

Is there a quick and easy way to achieve my expected result? 🙂

Advertisement

Answer

Option One:

JavaScript

Option 1 output:

JavaScript

Option 2:

JavaScript

Option 2 Output (unlike option 1, the array index starts from 0):

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement