Skip to content

Instantly share code, notes, and snippets.

@asvny
Created December 30, 2015 14:22
Show Gist options
  • Save asvny/c389f19352849b5ddd60 to your computer and use it in GitHub Desktop.
Save asvny/c389f19352849b5ddd60 to your computer and use it in GitHub Desktop.
var t = 'The quick brown fox jumped over the lazy dog' ;
const longestWord = (input) => {
let arr = input.split(' ');
let arrL = arr.map((word)=>word.length);
let max=arrL.reduce((prev,curr,i)=> curr > prev ? i : prev,0);
return arr[max];
}
longestWord(t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment