I am trying to determine the midpoint of the first sequence that appears when given multiple strings in a large array
For example:
var array = ["c6dafc", "c6dafc", "1d2129", "1d2129", "1d2129", "cfcfff", "cfcfff", "ffffff", "1d2129", "1d2129", "1d2129", "1d2129"]
Calling function: (find center index based on 1d2129
, if not found then search for 32cd32
)
var result = somefunction(["1d2129", "32cd32"]);
In the example above, the result should be 3
because the first occurrence of 1d2129
is at index 2
and the last is at index 4
not 11
. If 1d2129
does not appear, then it should search for 32cd32
.
Note: if the number of occurrences is odd, return the center index; if even, return centerPoint - 1