I have this sample JSON data:
[
{
category: {
selectedDate: { seconds: 1639903368, nanoseconds: 392000000 },
category1: true,
category2: true
},
name: "Sample 1"
}
];
There are some cases where category1
and category2
are true, but the selectedDate
is not present there. So how can I filter these where category 1
and category 2
are true
and that the selectedDate
exist?
These are my codes, however, this would not filter correctly.
const filter = users.filter(
(f) =>
f.choices.category1 == true &&
f.choices?.category2 == true &&
f.choices?.selectedDate !== null
);
console.log(booster);