Function to convert a string to an integer
function convert ( s ) { let val = 0 ; s = s . split ( " " ) . reverse ( ) . join ( " " ) ; let cur = 1 ; for ( let i = 0 ; i < s . length ; i ++ ) { val += ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) * cur ; cur *= 10 ; } return val ; }