Created
May 24, 2022 13:23
-
-
Save malko/e171226699a9bac3e1dda0abd91e3011 to your computer and use it in GitHub Desktop.
Get the key in a map that hold the max value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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