arrayIndexOf task is used to return the first index (position) at which a given element can be found in the array. The task returns -1 if the element is not found.
Potential Use Case
Suppose you have a list of email addresses and want to determine if an email record is listed in the correct department. The
arrayIndexOf task can be used to check whether the email exists or not. It will return the index number (position) where the email occurs. If the email is not found in the list, then your return result would be -1.
||Array||Required. The array to search.|
||Any||Required. The element to search for in the array.|
||Number||Optional. The index position to start the search at. Default is 0 (zero).|
||Number||The position of the element in the
In this IAP example:
arrvariable is statically specified as
searchElementreference variable is
fromIndexvariable will default to 0.
indexresult will return
2upon output, indicating that the
searchElement("Banana") is located at index position 2 in the array.
Note: The first element has position 0, the second element has position 1, and so on.