Task[edit]
Find the index of a string (needle) in an indexable, ordered collection of strings (haystack).

Raise an exception if the needle is missing.

If there is more than one occurrence then return the smallest index to the needle.

Extra credit
Return the largest index to a needle that has multiple occurrences in the haystack.

See also
 Search a list of records

var list:Vector.<String> = Vector.<String>(["Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie", "Bush", "Boz", "Zag"]);
function lowIndex(listToSearch:Vector.<String>, searchString:String):int
{
	var index:int = listToSearch.indexOf(searchString);
	if(index == -1)
		throw new Error("String not found: " + searchString);
	return index;
}
 
function highIndex(listToSearch:Vector.<String>, searchString:String):int
{
	var index:int = listToSearch.lastIndexOf(searchString);
	if(index == -1)
		throw new Error("String not found: " + searchString);
	return index;
}