← Back to challenges

Find the Longest Word

JavaScriptHardarraysstringsvalidationrecursion

Instructions

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.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.