Map to store frequency of all characters in the string
var mp = new Map ( ) ; str . split ( ' ' ) . forEach ( ch => { if ( mp . has ( ch ) ) mp . set ( ch , mp . get ( ch ) + 1 ) else mp . set ( ch , 1 ) } ) ;