Creating a HashMap containing char as a key and occurrences as a value
let map = new Map ( ) ; for ( let x of arr ) { if ( map . has ( x ) ) map . set ( x , map . get ( x ) + 1 ) ; else map . set ( x , 1 ) ; }