Find value at index i and length m .
let value = 0 ; for ( let j = 0 ; j < m ; j ++ ) { let c = str [ i + j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( c < 0 c > 9 ) { return - 1 ; } value = value * 10 + c ; } return value ; }