Skip to content

Instantly share code, notes, and snippets.

@suissa
Created October 14, 2017 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save suissa/90bb33d3054462acb7dce951dc327ff1 to your computer and use it in GitHub Desktop.
Save suissa/90bb33d3054462acb7dce951dc327ff1 to your computer and use it in GitHub Desktop.
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