Below is a JSON object that stores the ID and type of each object:
let jsonData = [
{"id": "1", "object": "pen"},
{"id": "4", "object": "bag"},
{"id": "2", "object": "paper"},
{"id": "5", "object": "bottle"},
{"id": "3", "object": "notepad"},
{"id": "1", "object": "pen"},
{"id": "4", "object": "bag"},
{"id": "3", "object": "notepad"},
{"id": "3", "object": "notepad"},
{"id": "1", "object": "pen"},
{"id": "2", "object": "paper"},
{"id": "1", "object": "pen"},
]
I would like to create a new array displaying each object with its corresponding count value in the format below:
|---------------------|------------------|
| Object | Unit |
|---------------------|------------------|
| Pen | 4 |
|---------------------|------------------|
| Paper | 2 |
|---------------------|------------------|
| Notepad | 3 |
|---------------------|------------------|
| Bag | 2 |
|---------------------|------------------|
| Bottle | 1 |
|---------------------|------------------|
In essence, the new array will showcase each object along with its respective count. Thank you in advance.