Write a function hasCommonElement(a, b) that checks if two arrays have at least one equal element. In other words, it checks that their intersection is not empty.
a and b is a number or a string. The arrays can be empty and can have repeated elements.true if some element of a is also in b, otherwise false.===: the number 1 and the string '1' are different, and 'a' and 'A' are different.false.A set of the elements of b makes the check fast for long arrays.
hasCommonElement([1, 2, 3], [3, 4])Returns true
hasCommonElement([1, 2], [3, 4])Returns false
hasCommonElement([1, 2], ['1'])Returns false
hasCommonElement([ 1, 2, 3 ], [ 3, 4 ])truehasCommonElement([ 1, 2 ], [ 3, 4 ])falsehasCommonElement([], [ 1, 2 ])falseHidden tests run on Submit.