Skip to content

Instantly share code, notes, and snippets.

@kishoreandra
Created August 2, 2022 17:28
Show Gist options
  • Save kishoreandra/11ef573bcf3ace784bb7762bcdd9a511 to your computer and use it in GitHub Desktop.
Save kishoreandra/11ef573bcf3ace784bb7762bcdd9a511 to your computer and use it in GitHub Desktop.
Filter with reduce - Eva (discord SH)
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const filters = [(item) => item > 4, (item) => item !== 6];
const filtered = array.reduce((acc, cur) => {
if(filters.every(filter => filter(cur))) return acc.concat(cur);
return acc;
}, []);
ref -> https://discordapp.com/channels/102860784329052160/565213527673929729/1004072869250203658
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment