Rearrange a string in the form of integer sum followed by the minimized character | function to return maximum volume ; separate digits and alphabets ; change digit sum to string ; change alphabet sum to string ; concatenate sum to alphabets string ; Driver code
function separateChar ( str ) { var n = str . length , digitSum = 0 ; var alphabetSum = 0 , j = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) digitSum += ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; else { alphabetSum += ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) + 1 ) ; alphabetSum %= 26 ; } } var sumStr = digitSum . toString ( ) ; var alphabetStr = String . fromCharCode ( alphabetSum + ' ' . charCodeAt ( 0 ) - 1 ) ; sumStr += alphabetStr ; return sumStr ; } var str = " " ; document . write ( separateChar ( str ) ) ;