Last active
September 10, 2020 13:56
-
-
Save daejinseok/9dbf1fcdc3eb7e1796532c05ee6c39fb to your computer and use it in GitHub Desktop.
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
function makeHashCount( arr ){ | |
const m = new Map(); | |
arr.forEach( k => { | |
m.set(k, (m.get(k)||0) + 1 ); | |
}) | |
return m; | |
} | |
console.log( makeHashCount([1,2,3,3]) ); | |
// Map(3) { 1 => 1, 2 => 1, 3 => 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment