Given an array of objects, iterate over it and change/add a few props while keeping most of the original props intact.
in javascript it would look like:
const trips = [
{ status: 1, name: "trip1", foo: "bar" },
{ status: 1, name: "trip2", foo: "bar" },
{ status: 3, name: "trip3", foo: "foobar" }]
const formatedTrips = trips.map(trip => ({
...trip,
status: 1,
foo: trip.foo === "bar" ? ` ${trips.name} bar` : "barbar"
}))
/**
* formatedTrips = [
{ status: 1, name: "trip1", foo: "trip1 bar" },
{ status: 1, name: "trip2", foo: "trip2 bar" },
{ status: 1, name: "trip3", foo: "barbar" }
]
*/