Hi! Quick question about array manipulation.
I’m building an array of objects { id, commentsCount }, initially empty, that gets updated from a child component event. Each time a user comments, the event returns the post ID.
The goal is to keep a temporary local array of posts and their comment counts to update the UI without refreshing or calling the API.
How should I handle adding/updating objects in this array with these two cases :
If an object with the same id exists → increment commentsCount
If not → add { id, commentsCount: 1 } to the array
Thanks you