← Back to challenges

Reverse Words Starting With a Particular Letter

JavaScriptHardstringshigher_order_functions

Instructions

Write a function that reverses all the words in a sentence that start with a particular letter.

Examples

specialReverse("word searches are super fun", "s")
➞ "word sehcraes are repus fun"

specialReverse("first man to walk on the moon", "m")
➞ "first nam to walk on the noom"

specialReverse("peter piper picked pickled peppers", "p")
➞ "retep repip dekcip delkcip sreppep"

Notes

  • Reverse the words themselves, not the entire sentence.
  • All characters in the sentence will be in lower case.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: H4ck3r Sp34k