Currently, I am developing a filter system that is based on checkboxes.
However, I am facing an issue where the JavaScript seems to ignore other conditions within the filter function when one condition is active.
filterData() {
return this.airlines.filter(x => {
if (this.filters.options.length != 0 || this.filters.airlines.length != 0) {
for (let i = 0; this.filters.options.length > i; i++) {
if (this.filters.options[i] == 0) {
return x.itineraries[0][0].stops == 0;
}
if (this.filters.options[i] == 1) {
return x.itineraries[0][0].segments[0].baggage_options[0].value > 0;
}
}
} else {
return x;
}
})
}
Although I understand that the "return" statement will stop the current loop, I'm struggling to find a way to address this problem effectively. Any suggestions?