Finding the maximum value from the map
let currentMax = 0 ; let arg_max = 0 ; for ( let [ key , value ] of occ . entries ( ) ) { if ( value > currentMax || ( value == currentMax && key > arg_max ) ) { arg_max = key ; currentMax = value ; } }