How to loop through all characters in a string and count the number of occurrences of each character and populate an object with the results? I came across this on Codewars and didn't find the answer specifically structured this way here on stackoverflow, and so I wanted to share my solution. I hope this is going to be helpful for someone out there.
Example input: "Apple" Output: {A: 1, p: 2, l: 1, e: 1}
Developing my solution, I needed to find out how to create a dynamic object using a for loop. And so, I found this to be particularly helpful:
https://stackoverflow.com/a/69328904/13200699
But, then I had to make a few additions to it, because my challenge was a bit different than that. And finally I came up with the solution below;