Skip to content

Instantly share code, notes, and snippets.

@dmidlo
Created November 22, 2015 22:57
Show Gist options
  • Save dmidlo/ed2a21c96913046de1ed to your computer and use it in GitHub Desktop.
Save dmidlo/ed2a21c96913046de1ed to your computer and use it in GitHub Desktop.
function findLongestWord(str) {
var charCount = 0;
var strArray = str.split(' ');
for(var i = 0;i < strArray.length ;i++)
{
if(strArray[i].length > charCount)
{
charCount = strArray[i].length;
}
}
return(charCount);
}
findLongestWord("The quick brown fox jumped over the lazy dog");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment