Print the frequency of each character in Alphabetical order | Javascript implementation of the approach ; Function to print the frequency of each of the characters of s in alphabetical order ; To store the frequency of the characters ; Update the frequency array ; Print the frequency in alphatecial order ; If the current alphabet doesn 't  appear in the string ; Driver code
let MAX = 26 ; function compressString ( s , n ) { let freq = new Array ( MAX ) ; freq . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) { freq [ s [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; } for ( let i = 0 ; i < MAX ; i ++ ) { if ( freq [ i ] == 0 ) continue ; document . write ( String . fromCharCode ( i + ' ' . charCodeAt ( ) ) + " " + freq [ i ] ) ; } } let s = " " ; let n = s . length ; compressString ( s , n ) ;