let's say i wanted refactor this approach, rather than using a for loop, is there any other way to do this dynamically
//to apply filter functions in one loop
const booleanFilterFunctions = [
(launchData) =>
launchData.launch_year === filterState.year ||
filterState.year === "0000",
(launchData) => launchData.launch_success === filterState.launch,
(launchData) => launchData.land_success === filterState.landing,
];
return (
<div className={styles.grid}>
{data
.filter((launchData) => {
let result = true;
for (let i of booleanFilterFunctions)
result = result && i(launchData);
return result;
})
.map((launchData) => (
<a key={launchData.flight_id} className={styles.card}>
<img alt={launchData.links.mission_patch_small} loading="lazy" src={launchData.links.mission_patch_small}></img>
<h3>
{launchData.mission_name} #{launchData.flight_number}
</h3>
</a>
))}
</div>);