I wanted to know is it possible to use the reduce method on arrays with strings as well?
For ex: If I have an array like this: [ 'm', 'o', 'o', 'n' ] then I can reduce it to an object like this: { m: 1, o: 2, n: 1 }, that counts the occurrences of all characters in the string.
But if instead I had a string "moon" I wouldn't be able to use the reduce method with it.
I know I can write a custom implementation for reduce, but is there something simpler?