Skip to content

Instantly share code, notes, and snippets.

@parkerziegler
Created January 30, 2022 18:17
Show Gist options
  • Select an option

  • Save parkerziegler/c6c09f18e763b880a3bf57eb6b664e42 to your computer and use it in GitHub Desktop.

Select an option

Save parkerziegler/c6c09f18e763b880a3bf57eb6b664e42 to your computer and use it in GitHub Desktop.

Revisions

  1. parkerziegler created this gist Jan 30, 2022.
    5 changes: 5 additions & 0 deletions max-in-map.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    function maxInMap<K>(map: Map<K, number>) {
    return [...map.entries()].reduce((acc, el) =>
    el[1] > acc[1] ? el : acc
    )[0];
    }