Skip to content

Instantly share code, notes, and snippets.

@spcbfr
Created July 13, 2021 19:46
Show Gist options
  • Save spcbfr/644856c4c0a3a613b766d65109a15571 to your computer and use it in GitHub Desktop.
Save spcbfr/644856c4c0a3a613b766d65109a15571 to your computer and use it in GitHub Desktop.
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