Skip to main content

Exercise 3: Find the Repeat

Given an array with at least two elements, return the element which is included more than once. If no element repeats, return false. If more than one element repeats, return any one of the repeating elements.

Input: [1, 'a']
Output: false

Input: ['abc', 'abc']
Output: 'abc'

Input: [-1, 0, 0, 1]
Output: 0

Sketch:

Script: