find first duplicate in array javascript