Returns the element of an array when it matches a condition