I have the following array:
[0:{
boat: "Laura"
date: "2022-05-14"
doy: 133
end: "22:00:00"
fname: "David"
lname: "Cross"
skipperid: 217
spots: 5
start: "09:00:00"
type: "RES"},
1:{
boat: "Avrora"
date: "2022-05-14"
doy: 133
end: "13:00:00"
fname: "Bob"
lname: "Smith"
skipperid: 1
spots: 3
start: "10:00:00"
type: "SAIL"}]
I apply the following to turn it into an object of arrays where the keys to each object is the skipperid.
daySails = daySails.reduce((b, a) => ({
...b,
[a.skipperid]: a
}), {});
could someone explain how this works?