13. Frequency Counter
EasyObjects~8 min
Given an array of strings, return an object mapping each value to the number of times it appears.
An empty array produces an empty object.
Examples
Example 1
- Input:
- items = ["a", "b", "a"]
- Output:
- { "a": 2, "b": 1 }
Example 2
- Input:
- items = []
- Output:
- {}
Constraints
0 <= items.length <= 1000Items are non-empty strings.