Guest User

Untitled

a guest
Feb 15th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. public countKeys(arr: any[]) {
  2. const result: any[] = [];
  3. for (const key of Array.from(new Set(arr))) {
  4. const item: any = {key: key, count: arr.filter(x => x === key).length};
  5. result.push(item);
  6. }
  7. return result;
  8. }
Add Comment
Please, Sign In to add comment