What is the cleanest way to assign a person's seat while looping over the available seats, when after assigning a person's seat, the movie ticket status must be marked unavailable. Would be open to using lodash methods as well.
const movieTickets = [
{
seat: "16B"
status: "available"
},
{
seat: "16c"
status: "available"
},
{
seat: "16D"
status: "available"
}
]
const people = [
{
name: "Bob"
seat: ""
},
{
name: "Susan"
seat: ""
},
{
name: "Timmy"
seat: ""
}
]
/**
* Current solution
* The problem is that ticket is not marked as unavailable, and I'm unsure of the cleanest way to do that, would love suggestions here
**/
const assignedPeople = people.map(person => {
person.seat = movieTickets.find(ticket => ticket.status === "available").seat
return person;
});