Store all characters and their frequencies in dictionary
var d = new Map ( ) ; s . split ( ' ' ) . forEach ( element => { if ( d . has ( element ) ) { d . set ( element , d . get ( element ) + 1 ) ; } else d . set ( element , 1 ) ; } ) ;