I have this array of objects
const unitsAndRates = [
{
propertyUnitType: "store",
propertyUnitRate: "20000",
numberOfUnit: 4
},
{
propertyUnitType: "duplex",
propertyUnitRate: "20000",
numberOfUnit: 3
}
];
and I need something like this generated array from the one above.
const generated = [
{
propertyUnitType: "store1",
propertyUnitRate: "20000"
},
{
propertyUnitType: "store2",
propertyUnitRate: "20000"
},
{
propertyUnitType: "store3",
propertyUnitRate: "20000"
},
{
propertyUnitType: "store4",
propertyUnitRate: "20000"
},
{
propertyUnitType: "duplex1",
propertyUnitRate: "20000"
},
{
propertyUnitType: "duplex2",
propertyUnitRate: "20000"
},
{
propertyUnitType: "duplex3",
propertyUnitRate: "20000"
}
];
How can I generate the output above considering the numberOfUnit?