I would like to know if there is a better option to create a copy of an object array with a new structure
Actually I do this (typescript):
const carModels = (carList: Array<CarModel>): Array<SelectValues> => {
const cars: Array<SelectValues> = []
carList.forEach((car: CarModel) =>
cars.push({
value: `/api/modeles/${car.id}`,
label: car.libelle,
})
)
return cars
}