Bonfire: Find the Longest Word in a String

function findLongestWord(str) {
  var cumle = str.split(' ');
  var kacKelime = cumle.length;
  var final = 0;
  for(var i = 0; kacKelime > i; i++) if(final < cumle[i].length) final = cumle[i].length;
  return final;
}
findLongestWord('The quick brown fox jumped over the lazy dog');

Leave a Reply