Created
October 14, 2017 10:26
-
-
Save suissa/90bb33d3054462acb7dce951dc327ff1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 words = [ | |
'oi', 'como', 'vai', 'você', 'seu', 'idiota' | |
] | |
const blacklist = [ | |
'idiota', 'babaca', 'fdp' | |
] | |
const verbs = [ | |
'vai', 'vou' | |
] | |
const cleanWords = ( blacklist ) => ( word ) => | |
!blacklist.includes( word ) | |
const filterWords = ( blacklist ) => ( words ) => | |
words.filter( cleanWords( blacklist ) ) | |
const filterBlacklist = filterWords( blacklist ) | |
const filterVerbs = filterWords( verbs ) | |
const wordsClean = filterBlacklist( filterVerbs( words ) ) | |
console.log( 'wordsClean: ', wordsClean ) | |
// wordsClean: [ 'oi', 'como', 'você', 'seu' ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment