What are some good approach to convert a customer list with name, product, cost to a unique customer list with user, total product and spent?

Asking for feedback on my approach, no code required. Given a customer list – id, name, product, cost. I am trying to convert this list into a new list that is sorted in a way that it returns unique user, the user’s total number of products bought, and total spent.

My initial thought: Create a new object array, run a loop on each object and append user name, product, and cost, to the new array if user is not already in it. If user is already in the new array, find the user and increment the user’s total product by 1. Total spent will be added to the existing amount.

Language: JavaScript/React

I read that I could create an Object Array and push each Object (user) to it, and each user would have those 3 properties (excluding id because I assume its auto generated).

var sample = new Array();
sample.push(new Object());

Draft pseudo code for the the process:

let usersArr = new Array();
ogSet.forEach(userData=> {
   if (!(userData.name in usersArr[any].name)) {
      usersArr.push(userData)
   } else {
      usersArr[matchedUser].totalNumberOfProduct++;
      usersArr[matchedUser].totalSpent+= userData.cost
   }
}
...
// print out 
usersArr.map(user => {
   console.log(user.name)
   console.log(user.totalNumberOfProduct)
   console.log(user.totalSpent)
}

Original JSON array:

[
  {
    "id": "1",
    "name": "Bill",
    "product": "chair",
    "cost": "222"
  }.
  {
    "id": "2",
    "name": "Bill",
    "product": "sofa",
    "cost": "9999"
  },
  {
    "id": "3",
    "name": "Steve",
    "Product": "Monitor",
    "Cost": "555"
  }
]
...

Result:

[
  {
    "id": "1",
    "name": "Bill",
    "totalNumberOfProduct": "2",
    "totalSpent": "10221"
  }
]
...

Any feedback/suggestions on the way I tackle this? What are some ways to optimize speed and time? Algorithms and React specific methods are welcome.