Created
September 25, 2019 03:49
-
-
Save jerolan/ea7b8fdf9d97e83e98c1f92d1c7c7c30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const regex = /\W|_/g; | |
function longest(acc, elem) { | |
if (acc.length < elem.length && !regex.test(elem)) return elem; | |
return acc | |
} | |
function longestWord(sen) { | |
return sen.split(" ").reduce(longest, ""); | |
} |
Author
jerolan
commented
Sep 25, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment