Add Q to the resulting string
sb += Q ; for ( var i = pos + 1 ; i < 26 ; i ++ ) { while ( freq [ i ] > 0 ) { var c = String . fromCharCode ( " " . charCodeAt ( 0 ) + i ) ; sb += c ; freq [ i ] -- ; } } document . write ( sb ) ; }