const dates = [
{arrival_date:'2019-01-01',departure_date:'2019-01-07'},
{arrival_date:'2019-01-07',departure_date:'2019-01-09'},
{arrival_date:'2019-01-10',departure_date:'2019-01-20'}
];
let is_filter_by_arrival_date = true;
let is_filter_by_dept_date = true;
I have an array called dates.
Also I have two Boolean variables is_filter_by_arrival_date and is_filter_by_dept_date.
Also I have another four variables.
let arrival_from = '';
let arrival_to = '';
let dept_from = '';
let dept_to = '';
What I want is if the Boolean variable is_filter_by_arrival_date is true. I need to filter my dates using arrival_from and arrival_to same as for the is_filter_by_dept_date.
What I have done up-to now is
let results = dates.filter(e => {if(is_filter_by_arrival_date){
e.arrival_date <= arrival_to && e.arrival_date >= arrival_to
}})
But I want to filter not only by the is_filter_by_arrival_date. I want both is_filter_by_arrival_date and is_filter_by_dept_date.
How do I achieve this using JavaScript.