Created
July 13, 2021 19:46
-
-
Save spcbfr/644856c4c0a3a613b766d65109a15571 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
let findLongestWordLength = (str) => { | |
let splitRegex = /[a-zA-z]+/gi | |
let longest = 0; | |
let words = str.match(splitRegex); | |
for(let i = 0; i < words.length; i++ ) { | |
let currWordLen = words[i].length; | |
if(currWordLen > longest) { | |
longest = currWordLen; | |
} | |
} | |
return longest | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment