Find the Longest Word

Published by Deep Xavier in

Write a function that will return the longest word in a sentence. In cases where more than one word is found, return the first one.

Examples

findLongest("A thing of beauty is a joy forever.") ➞ "forever"

findLongest("Forgetfulness is by all means powerless!") ➞ "forgetfulness"

findLongest("\"Strengths\" is the longest and most commonly used word that contains only a single vowel.") ➞ "strengths"

Notes

  • Special characters and symbols don't count as part of the word.
  • Return the longest word found in lowercase letters.
  • A recursive version of this challenge can be found in here.
Watch a quick demo on how Edabit works.