arobida
12/21/2017 - 3:57 PM

[Longest Word] Script for find the longest word in a sentence #vanilla #script

[Longest Word] Script for find the longest word in a sentence #vanilla #script

function findLongestWord(str) {
  var bigone=0;
  var word=str.split(" ");
  for(var i=0;i<word.length;i++){
    if(word[i].length>bigone){
      bigone=word[i].length; 
    }
  }
  return bigone;
}

//findLongestWord("The quick brown fox jumped over the lazy dog");