Title case in JavaScript
Capitalizes each word, with the small words most implementations get wrong.
function titleCase(text) {
return text
.toLowerCase()
.split(" ")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
}
Keywords and builtins used here
functionreturn
The run, in numbers
- Lines
- 7
- Characters to type
- 140
- Tokens
- 49
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 35 seconds.
Step 3 of 5 in Text, step 8 of 43 in Language basics.