I have a program that adds or removes cars to an array called pile so that the cars can later be selected based on filters and criteria. The code works as it is but I am trying to increase it's efficiency for later changes. Below is code to show what my question is:
if ( var1 == true ) {
pile.push(car1);
} else if ( var1 == false ) {
pile = pile.filter( removeCar );
}
function removeCar(elem) {
return String(elem[0][0]) !== 'Jeep';
}
What I want to do is for removeCar() to have two parameters so it is removeCar(elem, make) such that if make = 'Jeep' the code would function the same way. Unfortunately, as you can see removeCar is called by filter with no parameters and elem is automatically assigned to the current element.
How can I add parameters to the .filter( removeCar)?