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
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #JS #longest #word
ADD COMMENT
Topic
Name
6+3 =