I have a huge list of 4k+ softwareProductsoftware products.
My goal is simple. I have a list of products. Each of those products has a software value. I would like to extract each software occurrence and covert it into an object in the format {text, id}
.
The code below 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;
}, []);