Skip to content

Instantly share code, notes, and snippets.

@malko
Created May 24, 2022 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malko/e171226699a9bac3e1dda0abd91e3011 to your computer and use it in GitHub Desktop.
Save malko/e171226699a9bac3e1dda0abd91e3011 to your computer and use it in GitHub Desktop.
Get the key in a map that hold the max value
const getMapMaxValueKey = (map) => {
return map.size ? [...map.entries()]
.reduce((a, b) => a[1] >= b[1] ? a : b)[0]
: null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment