The IndexOf()
function returns the index of a string within another string. Will return 0 if the string was not found.
This function is case insensitive.
Syntax
IndexOf(searchInString, searchString)
Returns
Index of the string that is found within another string. If the string is not found, the function will return 0. The index of the first character is 1, the second character is 2, etc.
Parameters
- searchInString – the is the string in which the function will search for the searchString
- searchString – this is the string that is searched for
Examples
IndexOf("The quick brown fox jumps over the lazy dog", "JUMPS")
/* returns 21 */
IndexOf("The quick brown fox jumps over the lazy dog", "JUMPED")
/* returns 0 */