May
21st,
2017
https://www.freecodecamp.cn/challenges/find-the-longest-word-in-a-string
知识点
function findLongestWord(str) {
var arr= str.replace(/[^A-Za-z\s]/g,"").split(" ");
var longestWord=arr.reduce(function(prev,curr){
return prev.length>curr.length?prev:curr;
},"");
return longestWord.length;
}
findLongestWord("The quick brown fox jumped over the lazy dog");