To find the longest word in a string in JavaScript, do this:
string.split(' ').reduce((l, c) => c.length > l.length ? c : l)
.Here's how you do it:
const string = 'The quick brown fox jumped over the lazy dog';
const longest = string.split(' ').reduce((l, c) => c.length > l.length ? c : l);
console.log(longest); // jumped