Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

JS longest word

const wordsArray = ['1', '22', '222', 'longstring', '2222']
const longestWord = wordsArray.reduce((longestWord, currentWord) =>
    currentWord.length > longestWord.length ? currentWord: longestWord, '');
console.debug(longestWord); // longstring
 
PREVIOUS NEXT
Tagged: #JS #longest #word
ADD COMMENT
Topic
Name
5+3 =