Overview
Break a string into an array of words, rework each word and stitch them into a variable name or slug.
- split(separator) gives an array
- join(separator) gives a string
- Extra spaces create empty items
Short Course
split cuts a string into an array; join glues an array into a string.
Trap: a double space gives an empty item, so filter those out before
working on the words.
"2026-11-21".split("-"); // ["2026", "11", "21"]
"a b".split(" "); // ["a", "", "b"] — empty item!
"a b".split(" ").filter(w => w); // ["a", "b"]
["my", "post"].join("-"); // "my-post"
"word".slice(1); // "ord"
Task
Write toCamelCase(text): the first word in lower case, every next word with
a capital first letter and the rest lower case, ignoring extra spaces —
toCamelCase("hello big world") returns helloBigWorld.
Test Suites
Pending
Next
Output