I am trying to create a booking app and mark out the slots unavailable. The slots unavailable are in an array for example:
const unavailable = [ "11:00am a 12:00pm", "17:00pm a 18:00pm"]
and the total slots are
let slots = [ {
slot: "9:00am a 10:00am",
isReserved: false,
},
{
slot: "10:00am a 11:00am",
isReserved: false,
},
{ slot: "11:00am a 12:00pm", isReserved: false },
{
slot: "15:00pm a 16:00pm",
isReserved: false,
},
{
slot: "17:00pm a 18:00pm",
isReserved: false,
},
{
slot: "18:00pm a 19:00pm",
isReserved: false,
},
{ slot: "19:00pm a 20:00pm", isReserved: false },
];
my goal is to use the unavailable array and each value inside and find how to change that field to
isReserved: true
I've tried to filter like so
const matches = slots.filter((same) => same.slot === unavailable);
but does not work. What did kind of work was
const matches = slots.filter((same) => same.slot === unavailable[0]);
but that only matches the first value, and I still do not know how to change the isReserved field.