If the input is a String object, convert it to an array before iterating, to get the indexes