Evaluating decimal for current substring and printing it .
let sum = 0 , counter = 0 ; for ( let j = sub . length - 1 ; j >= 0 ; j -- ) { sum = ( sum + ( ( sub [ j ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) * Math . pow ( b , counter ) ) ) ; counter ++ ; } document . write ( sum + " " ) ; } }