Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public countKeys(arr: any[]) {
- const result: any[] = [];
- for (const key of Array.from(new Set(arr))) {
- const item: any = {key: key, count: arr.filter(x => x === key).length};
- result.push(item);
- }
- return result;
- }
Add Comment
Please, Sign In to add comment