if res remains INT_MAX , it means there are no characters that repeat only once or the string is empty
if ( res == Infinity ) return - 1 ; else return res ; } var str ; str = " " ; var firstIndex = firstNonRepeating ( str ) ; if ( firstIndex === - 1 ) document . write ( " " ) ; else document . write ( " " + str . charAt ( firstIndex ) ) ;