Skip to content

Instantly share code, notes, and snippets.

@ChousinRahit
Created September 3, 2023 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChousinRahit/1886037cfdd547de7538240ddb4b1527 to your computer and use it in GitHub Desktop.
Save ChousinRahit/1886037cfdd547de7538240ddb4b1527 to your computer and use it in GitHub Desktop.
// Longest Word
// Write a function that finds the longest word in a sentence and returns it.
// If two or more words are the biggest, return the word closest to the start of the sentence.
// Characters such as apostrophe, commas, periods, etc count as letters (e.g.O'Connor is 8 characters long).
// Examples
// longestWord("Hello darkness my old friend") ➞ "darkness"
// longestWord("Hello there mate") ➞ "Hello"
// longestWord("Kayla's toy is plastic") ➞ "Kayla's"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment