Created
August 10, 2022 14:39
-
-
Save kylemh/ee3aac9502127786255a87c3fb5d136d to your computer and use it in GitHub Desktop.
This file contains 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
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