Skip to content

Instantly share code, notes, and snippets.

@the-creature
Last active October 8, 2017 16:30
Show Gist options
  • Save the-creature/c7abbe921587e9c716b95120f3a3b51c to your computer and use it in GitHub Desktop.
Save the-creature/c7abbe921587e9c716b95120f3a3b51c to your computer and use it in GitHub Desktop.
ES6 Filter, Sort, Split function
const sentence = ( p = 'text some txt' ) => p.split(' ').filter(v => !(v.length % 2)).sort((a, b) => a.length - b.length).toString().replace(/\W/g, ' ');
sentence('longer sentence with in to blah!'); // "in to with longer sentence"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment