I am currently dealing with an array called serialNumbers, which can have different structures. For example:
lot: 1 Serial: 2
lot: 1 Serial: 3
lot: 1 Serial: 4
...or it could look like this:
lot: 1 Serial: 5
lot: 1 Serial: 9
lot: 8 Serial: 2
lot: 8 Serial: 4
In my attempt to manipulate the data, I created a dictionary named dictSerials using the following code:
var dictSerials = []
if (serialNumbers.length > 0)
for (var i of serialNumbers) {
dictSerials.push({
key: i.value.lot,
value: i.value.serial
})
}
However, my desired outcome is to have an object structured like this:
Key: 1 Value: 2, 3, 4, 5, 9
Key: 8 Value: 2, 4
If anyone has insights on how to achieve this, your assistance would be greatly appreciated. Thank you!