here the bsolute difference of ascii value is considered
if ( Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) > Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; else s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; } else if ( s [ i ] > " " && s [ i ] < " " ) { if ( Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) > Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; else s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; } else if ( s [ i ] > " " && s [ i ] < " " ) { if ( Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) > Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; else s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; } else if ( s [ i ] > " " && s [ i ] < " " ) { if ( Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) > Math . abs ( s [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) ) s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; else s = s . substring ( 0 , i ) + " " + s . substring ( i + 1 ) ; }