Skip to main content

Ex Add Two Arrays

Description

This exercise consists of creating a function that receives two arrays and returns a new array containing only the common elements between the first two arrays. In other words, the function should filter the elements that appear in both arrays and return them in a new array. For example, if the first array is ["A", "B", "C", "D"] and the second array is ["B", "D", "F", "H"], the function should return a new array containing only "B" and "D".

Example

Input - ["A", "B", "C", "D"]
Input - ["B", "D", "F", "H"]
Output - ["B", "D"]