function longestWord(s: string): string {
const words: string[] = s.split(/\s+/);
return words.reduce((max: string, w: string) =>
w.length > max.length ? w : max
, "");
}
console.log(longestWord("Could you recommend a good restaurant nearby?"));
/*
run:
"restaurant"
*/