Noob Question
Please tell me a better way to do this if u know of any? Is ternary only option?


const accumulator: Record<string, any> = {}
const postings = [
{
sceneId: '123',
count: 1,
dl: ''
},
{
sceneId: '123',
count: 2,
dl: ''
},
{
sceneId: '144',
count: 2,
dl: ''
}
]
for (const posting of postings) {
const { sceneId, count } = posting
if (accumulator[sceneId]) {
accumulator[sceneId].count += count
} else {
accumulator[sceneId] = { ...posting }
}
}