Function to return the count of sub - strings starting from startIndex that are also the prefixes of str
function subStringsStartingHere ( str , n , startIndex ) { var count = 0 , i = startIndex + 1 ; while ( i <= n ) { if ( str . startsWith ( str . substring ( startIndex , i ) ) ) { count ++ ; } else break ; i ++ ; } return count ; }