← Back to challenges

Capital Split

JavaScriptHardstringsloops

Instructions

Create a function which adds spaces before every capital in a word. Uncapitalize the whole string afterwards.

Examples

capSpace("helloWorld") ➞ "hello world"

capSpace("iLoveMyTeapot") ➞ "i love my teapot"

capSpace("stayIndoors") ➞ "stay indoors"

Notes

The first letter will stay uncapitalized.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Probabilities (Part 1)