Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript select element have long word

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"));
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #select #element #long #word
ADD COMMENT
Topic
Name
9+5 =