Created
February 17, 2020 05:01
-
-
Save bitfishxyz/7d1456ea24ef69b699ae25b4cbb7206f 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
let arr = [1,2,35,33,5,3,3,23,5,6,1,44,33,6]; | |
let resultMap = arr.reduce(function(result, ele){ | |
if (ele in result) { | |
result[ele]++; | |
} else { | |
result[ele] = 1; | |
} | |
return result; | |
}, {}); | |
console.log(resultMap); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment