📌  相关文章
📜  javascript 选择元素有长字 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:55.130000             🧑  作者: Mango

代码示例1
function longer(champ, contender) {
  return (contender.length > champ.length) ? contender : champ;
}

function longestWord(str) {
  var words = str.split(' ');
  return words.reduce(longer);
}

console.log(longestWord("The quick brown fox jumped over the lazy dogs"));