← Back to challenges

White Spaces Between Lower and Uppercase Letters

JavaScriptHardregexformattingstrings

Instructions

Write a function that inserts a white space between every instance of a lower character followed immediately by an upper character.

Examples

insertWhitespace("SheWalksToTheBeach") ➞ "She Walks To The Beach"

insertWhitespace("MarvinTalksTooMuch") ➞ "Marvin Talks Too Much"

insertWhitespace("TheGreatestUpsetInHistory") ➞ "The Greatest Upset In History"

Notes

Each word in the phrase will be at least two characters long.

javascript
Loading editor…
⌘ ↵ to run
Walks through the solution with reasoning and edge cases.