← Back to challenges

Array of Word Lengths

JavaScriptHardarrayslanguage_fundamentals

Instructions

Create a function that takes an array of words and transforms it into an array of each word's length.

Examples

wordLengths(["hello", "world"]) ➞ [5, 5]

wordLengths(["Halloween", "Thanksgiving", "Christmas"]) ➞ [9, 12, 9]

wordLengths(["She", "sells", "seashells", "down", "by", "the", "seashore"]) ➞ [3, 5, 9, 4, 2, 3, 8]

Notes

  • No test case will contain punctuation.
  • Arrays can be of various lengths.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: How Many D's Are There?