Do school mathematics , compute difference of current digits and carry
let sub = ( ( str1 [ i + diff ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) - ( str2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) - carry ) ; if ( sub < 0 ) { sub = sub + 10 ; carry = 1 ; } else carry = 0 ; str += sub . toString ( ) ; }