Calculate the frequency
for ( var i = 0 ; i < chars . length ; i ++ ) { if ( freq . has ( chars [ i ] ) ) freq . set ( chars [ i ] , freq . get ( chars [ i ] ) + 1 ) else freq . set ( chars [ i ] , 1 ) }