Not sure why everyone went for the `Map` version when in JS every object is
basically the equivalent of a `Map` already :-)
```js
let m = Array.from("mainn").reduce((m,k) => ((m[k] = 1 + (m[k] | 0)), m),
{});
```
looks a win to me, if you need to check or drop chars from the string I
would probably do it once before passing that to `Array.from`
Agreed with Kevin this is rather a StackOverflow like question :-)
Best Regards
On Tue, Apr 28, 2015 at 1:19 PM, Kevin Smith <[email protected]> wrote:
> Another option:
>
> var map = new Map;
> Array.from("mainn")
> .map(c => c.toLowerCase())
> .forEach(c => map.set(c, (map.get(c) | 0) + 1));
>
> This kind of question is probably better left for StackOverflow, however.
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss