Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Counter {
- constructor() {
- this.map = {};
- }
- add(key) {
- if (this.map[key]) {
- this.map[key]++;
- }
- else {
- this.map[key] = 1;
- }
- }
- print() {
- console.log(this.map);
- }
- count() {
- return Object.keys(this.map).length;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement