So I'm just needing to return a value as true/false for a list of dictionaries.
I need to check if the date key in these dictionaries contains currentDate and then flag as true.
This will be used in conjunction with moment-timezones to check if it's a public holiday so my work can turn off our phone lines.
Example is:
const currentDate = '2022-01-26';
arr =
[
{
date: '2022-01-01 00:00:00',
start: 2021-12-31T13:00:00.000Z,
end: 2022-01-01T13:00:00.000Z,
name: "New Year's Day",
type: 'public',
rule: '01-01 and if saturday,sunday then next monday'
},
{
date: '2022-01-03 00:00:00',
start: 2022-01-02T13:00:00.000Z,
end: 2022-01-03T13:00:00.000Z,
name: "New Year's Day",
type: 'public',
rule: '01-01 and if saturday,sunday then next monday'
},
{
date: '2022-01-26 00:00:00',
start: 2022-01-25T13:00:00.000Z,
end: 2022-01-26T13:00:00.000Z,
name: 'Australia Day',
type: 'public',
rule: '01-26 if saturday,sunday then next monday'
}
]
Closest I've got is using:
holiday.forEach(function(d){
console.log(d.date.includes(currentDate));
});
Which in this example would return:
false
false
true
I'm struggling to convert this into an 'if' statement when if one value is true I can perform another action.
Thanks in advance.