If str [ i ] is between 0 and 9
if ( str [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { num [ str [ i ] . charCodeAt ( 0 ) - 48 ] = i ; }