Skip to content

Instantly share code, notes, and snippets.

@kylemh
Created August 10, 2022 14:39
Show Gist options
  • Save kylemh/ee3aac9502127786255a87c3fb5d136d to your computer and use it in GitHub Desktop.
Save kylemh/ee3aac9502127786255a87c3fb5d136d to your computer and use it in GitHub Desktop.
function getLongWordsFromString(text) {
const lowerCased = text.toLocaleLowerCase().trim();
const words = lowerCased.split(/\s+|\W+/); // split on any whitespace and non-word character
const longWords = words.filter(word => word.length > 5);
return longWords.length > 0 ? longWords.join(', ') : '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment