I have an array of objects
const workSchedule = [
{
name: 'a',
age: 21,
workDays: {
monday: {isavailable:true}, tuesday:{isavailable:false}, wednesday:{isavailable:true}, thursday:{isavailable:true}, Friday:{isavailable:false}
}
},
{
name: 'b',
age: 22,
workDays: {
monday: {isavailable:false}, tuesday:{isavailable:false}, wednesday:{isavailable:true}, thursday:{isavailable:false}, Friday:{isavailable:false}
}
}
]
and I have a string variable which have a selected Day
const day='Monday'
Now I want to check if the person A or B is available on monday or not?
2
Answers
You can achieve this simply with filter method.
Try like this,