I have a huge list of 4k+ softwareProduct
.
My goal is simple, I have a list of products. Each of those products have a software value.
I would like to extract each software occurrence and covert it into an object {text, id}
The code bellow works as I need, but I would like to know if you have a better way to do it 🙂
softwareProducts.reduce((acc = [], {software_id, software_name}) => {
if (acc.find((row) => row.id === software_id) === undefined) {
acc.push({
text: software_name,
id: software_id
})
}
return acc;
}, []);