I've flattened an array like this: let playerPool = [...new Set(array.flat(1))];
Which has an output like this: ["Howard Bell", "Matt Blair", "Dave Custer"]
How can I turn this into an array of objects? I want to update the above so the format is like this:
[ {Name: "Howard Bell", Count: "0"}, {Name: "Matt Blair", Count: "0"}, {Name: "Dave Custer", Count: "0"} ]
I was trying to set this up by looping through the playerPool array but I get the following error: TypeError: Cannot set property 'Name' of undefined
let playerPool = [...new Set(array.flat(1))];
let playerObjects = [];
for(let i = 0; i < playerPool.length; i++) {
playerObjects[i].Name = playerPool[i];
playerObjects[i].Count = 0;
}
My goal is to be able to reference each property individually like this playerObjects[0].Count so I can later update the count value.