Created
August 2, 2022 17:28
-
-
Save kishoreandra/11ef573bcf3ace784bb7762bcdd9a511 to your computer and use it in GitHub Desktop.
Filter with reduce - Eva (discord SH)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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