Skip to content

Instantly share code, notes, and snippets.

@bitfishxyz
Created February 17, 2020 04:29
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 bitfishxyz/5a82992cfb5ff2fd08038c38ea73bda2 to your computer and use it in GitHub Desktop.
Save bitfishxyz/5a82992cfb5ff2fd08038c38ea73bda2 to your computer and use it in GitHub Desktop.
function count(arr){
let result = new Map();
for(let ele of arr){
if (result.get(ele) == undefined) {
result.set(ele, 1);
} else {
result.set(ele, result.get(ele) + 1);
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment