Find The Longest Word

Published by Deep Xavier in

Write a recursive 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("I will and ever will be gratefully and perpetually loving you Tesh!😘") āžž "perpetually"

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

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

findLongest("The word strengths is the longest and most commonly used word with 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 via this link.
Watch a quick demo on how Edabit works.