Extract first digit and first two digits
let firstDigit = ( str [ 0 ] - ' ' ) ; let firstTwoDigit = 0 ; if ( str . length >= 2 ) { firstTwoDigit = ( str [ 0 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) * 10 + ( str [ 1 ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ;