I am dealing with an array Object
[
{ product: "Product A", inStock: 3, onHold: 1, soldOut: 2 },
{ product: "Product B", inStock: 2, onHold: 0, soldOut: 1 }]
I am struggling to convert it into the new array format below. Any assistance would be greatly appreciated
[
{ inStock: 1, product: "Product A" },
{ inStock: 1, product: "Product A" },
{ onHold: 1, product: "Product A" },
{ soldOut: 1, product: "Product A" },
{ soldOut: 1, product: "Product A" },
{ inStock: 1, product: "Product B" },
{ inStock: 1, product: "Product B" },
{ soldOut: 1, product: "Product B" },
]
If the onHold value is 0, it should not appear in the new array