返回提供的句子中最長的單詞的長度。html
返回值應該是一個數字。ui
function findLongestWord(str) { var arr = str.split(" "); var maxLength = 0; for(var i = 0; i < arr.length; i++){ if(arr[i].length > maxLength){ maxLength = arr[i].length; } } return maxLength; } findLongestWord("The quick brown fox jumped over the lazy dog");