I have some code where I am looping through some records in a table, and whilst doing this I'm organising this data into a JavaScript object array.
For example the data below.
I need to ensure that if a record "Name" has already been recorded, then rather than create a new item it uses the existing item so that the end result will be an object or array like this:
{
"bobjones": {
"sessions": 7
},
"annfrank": {
"sessions": 4
},
"fredsmith": {
"sessions": 4
}
}
Doing this in PHP is easy, but I'm struggling with this in JS due to the way keys are interpreted. Could somebody provide some direction?