Hi Community!
I’ve read the MDN web docs on logical operators
as well as several other online resources, but I am still wrestling with this one…
I am trying to filter through a list of cases to figure out which ones were active during this financial year… but I keep failing. Specifically, I’d like to use the following logic:
- If a case came into the system after X date, and it’s still open, add it to the list.
- If a case came in to the system after X date, and closed before Y date, add it to the list
- Forget everything else.
I’ve tried this:
cases_handled_fy19 = case_data.filter(function(case_data) {
return Date.parse(case_data.closure_date) < case_data.case_status == "Open" ||
Date.parse(case_data.closure_date) > Date.parse(2018, 6, 30) &&
Date.parse(case_data.closure_date) < Date.parse(2019, 7, 1)
})
… but the result is incorrect.
Narrowing it down:
cases_handled_fy19_alt2 = case_data.filter(function(case_data) {
return Date.parse(case_data.closure_date) < Date.parse(2019, 6, 1) && case_data.case_status == "Open"
})
… returns 0 objects, yet I know that the data has open cases that were received before July 01, 2019
Here’s a link:
Would someone be willing to help me understand how to write this function? I appreciate this might be the wrong place to ask (is it’s not an observable-specific question). Please forgive (or kindly reprimand me for future reference).
Thank you!!