Skip to content

Instantly share code, notes, and snippets.

@hmcq6
Last active June 7, 2017 23:13
Show Gist options
  • Save hmcq6/8c4978d861e10188065d7a4109dec085 to your computer and use it in GitHub Desktop.
Save hmcq6/8c4978d861e10188065d7a4109dec085 to your computer and use it in GitHub Desktop.
let searchTerms = searchBox.value.match(/\S+/g) || []; // "People's Republic"
$children.filter((_, { textContent }) => ( // "People's Republic of Bangladesh"
!searchTerms.reduce((all, term) => ( // [ "People's", "Republic" ]
all && textContent.
match(/\S+/g). // [ "People's", "Republic", "of", "Bangladesh" ]
reduce((any, word) => any || word.includes(term), false) // true
), true) // Remove from array to be hidden if all search terms have a match
)).hide();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment