function findLongestWord(str) {
var arr = str.split(' ');
var longest = "";
for(var i=0; i<arr.length; i++){
if(arr[i].length > longest.length){
longest = arr[i];
}
}
return longest.length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");
No comments:
Post a Comment